java - How to Show in TimePickerDialog extra 1 Hours -
how add 1 hour in time picker dialog. eg.:- if current hour 4.00 pm want show 5.00 pm in time picker.
final calendar c = calendar.getinstance(); c.add(calendar.hour,1); mhour = c.get(calendar.hour_of_day); mminute = c.get(calendar.minute); // launch time picker dialog timepickerdialog = new timepickerdialog(checkout.this, new timepickerdialog.ontimesetlistener() { @override public void ontimeset(timepicker view, int hourofday, int minute) { tvtimeselect.settext("delivery time : "+hourofday + ":" + minute); timepickerdialog.dismiss(); } }, mhour, mminute, false); timepickerdialog.show();
please tell me solution ...
you need maintain consistency. if getting hour_of_day need set same
option 1 : using hour_of_day
final calendar c = calendar.getinstance(); c.add(calendar.hour_of_day,1); mhour = c.get(calendar.hour_of_day); mminute = c.get(calendar.minute); // launch time picker dialog timepickerdialog = new timepickerdialog(checkout.this, new timepickerdialog.ontimesetlistener() { @override public void ontimeset(timepicker view, int hourofday, int minute) { tvtimeselect.settext("delivery time : "+hourofday + ":" + minute); timepickerdialog.dismiss(); } }, mhour, mminute, false); timepickerdialog.show();
option 2 : using hour
final calendar c = calendar.getinstance(); c.add(calendar.hour,1); mhour = c.get(calendar.hour); mminute = c.get(calendar.minute); // launch time picker dialog timepickerdialog = new timepickerdialog(checkout.this, new timepickerdialog.ontimesetlistener() { @override public void ontimeset(timepicker view, int hourofday, int minute) { tvtimeselect.settext("delivery time : "+hourofday + ":" + minute); timepickerdialog.dismiss(); } }, mhour, mminute, false); timepickerdialog.show();
Comments
Post a Comment