logo
down
shadow

Date picker Not Working on API 26


Date picker Not Working on API 26

By : deathcount248
Date : November 23 2020, 03:01 PM
Any of those help use System.currentTimeMillis()for Max date this will return current date in Milli Seconds . and for min use Calender.! If you want your app to work Completely fine on each Android Version follow my Example Code .! Date Picker Example
code :
 Calendar calendar = Calendar.getInstance();

        year = calendar.get(Calendar.YEAR);
        month = calendar.get(Calendar.MONTH);
        day = calendar.get(Calendar.DAY_OF_MONTH);

        datePickerDialog = new DatePickerDialog(getActivity(), onDateSet,
                year, month, day);

        // calendar.add(Calendar.DATE, Constants.DateAndMonth.CURRENT_DAY);//Current day
        datePickerDialog.getDatePicker().setMaxDate(System.currentTimeMillis());
        // Set the Calendar new date as maximum date of date picker
        datePickerDialog.getDatePicker().setMaxDate(calendar.getTimeInMillis());

        // Subtract 90 days from Calendar updated date
        calendar.add(Calendar.DATE, -Constants.DateAndMonth.LAST_NINETY_DAY);

        // Set the Calendar new date as minimum date of date picker
        datePickerDialog.getDatePicker().setMinDate(calendar.getTimeInMillis());

        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
            datePickerDialog.setTitle("");//Prevent Date picker from creating extra Title.!
        }


Share : facebook icon twitter icon
Time picker stops working after date picker is added

Time picker stops working after date picker is added


By : mostafavi
Date : March 29 2020, 07:55 AM
wish helps you I'm building an app that displays a date picker and a time picker on the click of two seperate buttons. I first added in the time picker and it was all working fine, I then proceeded to add the date picker which also works fine. The problem here being that when I added in the date picker, it casused the time picker to stop working. I know they both work and i'm 90% sure it is because of the structure of my code but being that i'm completely new to android and java development I can't work out where i'm going wrong. Any help would be appreciated. , Give this a try:
code :
    import java.util.Calendar;

    import android.app.Activity;
    import android.app.AlertDialog;
    import android.app.DatePickerDialog;
    import android.app.DatePickerDialog.OnDateSetListener;
    import android.app.Dialog;
    import android.app.TimePickerDialog;
    import android.app.TimePickerDialog.OnTimeSetListener;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.content.pm.ActivityInfo;
    import android.os.Bundle;
    import android.telephony.SmsManager;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.TimePicker;

    public class SettingsScreen extends Activity {


private TextView tvDisplayTime;
private TimePicker timePicker1;
private Button btnChangeTime;

private int hour;
private int minute;

static final int TIME_DIALOG_ID = 999;

Button change_date_but;
TextView display_txt;
public static final int Date_dialog_id = 1;

// date
private int mYear;
private int mMonth;
private int mDay;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.screen_settings);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

final EditText inputTxt1 = (EditText) findViewById(R.id.conPhoneNum);    
Button saveBtn1 = (Button) findViewById(R.id.btnSave1);

setCurrentTimeOnView();
//addListenerOnButton();
change_date_but = (Button) findViewById(R.id.change_button_id);
display_txt = (TextView) findViewById(R.id.display_id);
change_date_but = (Button) findViewById(R.id.change_button_id);
Button retTimeBtn = (Button) findViewById(R.id.btnRetTime);
Button homeButton = (Button) findViewById(R.id.btnHome);
btnChangeTime = (Button) findViewById(R.id.btnChangeTime);



change_date_but.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
    OnDateSetListener mDateSetListener = null;
    DatePickerDialog DPD = new DatePickerDialog(
    SettingsScreen.this, mDateSetListener, mYear, mMonth, mDay);
    DPD.show();
    }

    final Calendar c = Calendar.getInstance();{
        mYear = c.get(Calendar.YEAR);
        mMonth = c.get(Calendar.MONTH);
        mDay = c.get(Calendar.DAY_OF_MONTH);}
        /*void updateDisplay1() {
        }*/
        });


        saveBtn1.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View view) {
              String phoneNum1 = inputTxt1.getText().toString();
              savenum1(phoneNum1);

      //Intent passIntent = new Intent();
      //passIntent.putExtra("phoneNum", phoneNum1);

        }
        });



homeButton.setOnClickListener(new View.OnClickListener(){
    public void onClick(View view) {
        startHome();
        }
        });



retTimeBtn.setOnClickListener(new OnClickListener()
        {
  @Override
  public void onClick(View view) {
    //returnTime();

          } 
       });






    btnChangeTime.setOnClickListener(new OnClickListener() {

        @SuppressWarnings("deprecation")
        @Override
        public void onClick(View v) {

            showDialog(TIME_DIALOG_ID);
        }
    }); 


    }















    //display current time
public void setCurrentTimeOnView() {

    tvDisplayTime = (TextView) findViewById(R.id.tvTime);
    timePicker1 = (TimePicker) findViewById(R.id.timePicker1);

    final Calendar c = Calendar.getInstance();
    hour = c.get(Calendar.HOUR_OF_DAY);
    minute = c.get(Calendar.MINUTE);

    // set current time into textview
    tvDisplayTime.setText(
           new StringBuilder().append(pad(hour))
                              .append(":").append(pad(minute)));

    // set current time into timepicker
    timePicker1.setCurrentHour(hour);
    timePicker1.setCurrentMinute(minute);

}



private Object pad(int minute2) {
    // TODO Auto-generated method stub
    return null;
}


@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case TIME_DIALOG_ID:

        OnTimeSetListener timePickerListener = null;
        // set time picker as current time
        return new TimePickerDialog(this, 
                                 timePickerListener, hour, minute,false);

    }
    return null;
}



    /*

@Override
@Deprecated
protected void onPrepareDialog(int id, Dialog dialog) {
// TODO Auto-generated method stub
super.onPrepareDialog(id, dialog);
((DatePickerDialog) dialog).updateDate(mYear, mMonth, mDay);
}

private DatePickerDialog.OnDateSetListener mDateSetListener = new
        DatePickerDialog.OnDateSetListener() {

        public void onDateSet(DatePicker view, int year, int monthOfYear,
         int dayOfMonth) {
        mYear = year;
        mMonth = monthOfYear;
        mDay = dayOfMonth;
        updateDisplay();
         }
        };



        private void updateDisplay() {
            // TODO Auto-generated method stub
            display_txt.setText(new StringBuilder()
            // Month is 0 based so add 1
            .append(mMonth + 1).append("-").append(mDay).append("-")
            .append(mYear));

            }
        */





public void startHome() {
   Intent launchHome = new Intent();
   launchHome.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
   launchHome.setClassName(this,"com.becatech.gsmzonecontroller.MainActivity");
   startActivity(launchHome);     
}






public void savenum1(String phoneNum1) {

AlertDialog.Builder dlgAlert  = new AlertDialog.Builder(this);

dlgAlert.setMessage("Saved " + phoneNum1);
dlgAlert.setPositiveButton("OK", null);
dlgAlert.setCancelable(true);

dlgAlert.setPositiveButton("Ok",
    new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
          //dismiss the dialog  
        }
    });    
dlgAlert.create().show();
}





public void returnTime(){

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("", null, "#TU?", null, null);

}
    }
Magento date picker is not working when current date is disable

Magento date picker is not working when current date is disable


By : user3601968
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Finally I got the solution. In js/calendar/calendar.js there is a variable currentDateEl. By default it is null.You just need to set this.currentDateEl to current date.
code :
var currentDate = new Date();
var day = currentDate.getDate();
var month = currentDate.getMonth() + 1;
var year = currentDate.getFullYear();
var dmy =  day + "/" + month + "/" + year;
this.currentDateEl = dmy;
Datetime picker validation start date should be less than end date not working

Datetime picker validation start date should be less than end date not working


By : Peter
Date : March 29 2020, 07:55 AM
wish of those help , Try this. Its working for me.
code :
var startDate;
         $("#startdate").datetimepicker({
                     timepicker:true,
                     closeOnDateSelect:false,
                     closeOnTimeSelect: true,
                     initTime: true,
                     format: 'd-m-Y H:m',
                     minDate: 0,
                     roundTime: 'ceil',
                     onChangeDateTime: function(dp,$input){
                               startDate = $("#startdate").val();
                                                           }
                                                           });
        $("#enddate").datetimepicker({
                     timepicker:true,
                     closeOnDateSelect:false,
                     closeOnTimeSelect: true,
                     initTime: true,
                     format: 'd-m-Y H:m',
                     onClose: function(current_time, $input){
                            var endDate = $("#enddate").val();
                            if(startDate>endDate){
                                   alert('Please select correct date');
                             }
             }
              });
Calling radio button (click event) on changing date of jquery date picker not working

Calling radio button (click event) on changing date of jquery date picker not working


By : Novus3013
Date : March 29 2020, 07:55 AM
seems to work fine Since it's dynamically added , you need to use event delegation
code :
$(document).ready(function () {
    $('#showavialabletime').on('change','input[name=datetime]', function() {
       var date=$('input[name=datetime]:checked').val(); 
       alert(date);
    });
});
date picker not working if dropdown with multiselection works and multi selection not working if date picker works

date picker not working if dropdown with multiselection works and multi selection not working if date picker works


By : NrGtic
Date : March 29 2020, 07:55 AM
I wish this helpful for you You can try this working example of both datepicker and multiselect as per you want. I have tested in my local
code :
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>asdasd</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
    <script src="https://www.aspsnippets.com/demos/361/Scripts/jquery.dynDateTime.min.js" type="text/javascript"></script>
    <script src="https://www.aspsnippets.com/demos/361/Scripts/calendar-en.min.js" type="text/javascript"></script>
    <link href="https://www.aspsnippets.com/demos/361/Styles/calendar-blue.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        $(document).ready(function () {
            $("#<%=TextBox1.ClientID %>").dynDateTime({
                showsTime: true,
                ifFormat: "%Y/%m/%d %H:%M",
                daFormat: "%l;%M %p, %e %m, %Y",
                align: "BR",
                electric: false,
                singleClick: false,
                displayArea: ".siblings('.dtcDisplayArea')",
                button: ".next()"
            });
        });
    </script>

    <%--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>--%>
    <script src="http://hemantnegi.github.io/jquery.sumoselect/javascripts/jquery.sumoselect.js"></script>
    <link href="http://hemantnegi.github.io/jquery.sumoselect/stylesheets/sumoselect.css" rel="stylesheet" />

    <script type="text/javascript">
        $(document).ready(function () {
            $(<%=lstBoxTest.ClientID%>).SumoSelect({ selectAll: true });
            });
    </script>
    <style type="text/css">
        body {
            font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
            color: #444;
            font-size: 13px;
        }

        p, div, ul, li {
            padding: 0px;
            margin: 0px;
        }
    </style>
</head>
<body>
    <form runat="server">
        <asp:TextBox ID="TextBox1" runat="server" ReadOnly="true"></asp:TextBox>
        <img src="calender.png" />
        <br />
        <br />
        <br />
        <asp:ListBox runat="server" ID="lstBoxTest" SelectionMode="Multiple">
            <asp:ListItem Text="Red" Value="0"></asp:ListItem>
            <asp:ListItem Text="Green" Value="1"></asp:ListItem>
            <asp:ListItem Text="Yellow" Value="2"></asp:ListItem>
            <asp:ListItem Text="Blue" Value="3"></asp:ListItem>
            <asp:ListItem Text="Black" Value="4"></asp:ListItem>
        </asp:ListBox>

    </form>
</body>
</html>
shadow
Privacy Policy - Terms - Contact Us © voile276.org