android - How to pass the default time to time picker dialog fragment -
i have created time picker fragment.it shows current timing in dialog box.i want set default time.what setting default timing in dialog box.
you can this:
declare default time.. 20:00
mcurrenttime = calendar.getinstance(); int hour = 20; int minute = 0;
then dialog
timepickerdialog mtimepicker; mtimepicker = new timepickerdialog(addmedicine.this, new timepickerdialog.ontimesetlistener() { @override public void ontimeset(timepicker timepicker, int selectedhour, int selectedminute) { timepicker.setis24hourview(true); if(db.getalarm3().contains(selectedhour + ":" + selectedminute+" : 0")){ alarm3.settext( selectedhour + ":" +( selectedminute+1)); } else{ alarm3.settext( selectedhour + ":" + selectedminute); } mcurrenttime.set(calendar.hour_of_day,selectedhour); mcurrenttime.set(calendar.minute,selectedminute); mcurrenttime.set(calendar.second,0); // alarm3.settext(string.valueof(l3)+" ../.. "+string.valueof(calendar.getinstance().gettimeinmillis())); } }, hour, minute, true);//yes 24 hour tim mtimepicker.settitle("select time"); mtimepicker.show();
now time picker dialog appear 20:00 on it.
Comments
Post a Comment