dialog - Android: Change button text in DatePickerDialog / TimePickerDialog -
i have got datepickerdialog. in default configuration works fine.
datepickerdialog dialog = new datepickerdialog( view.getcontext(), new ondatesetlistener() { @override public void ondateset(datepicker picker, int year, int monthofyear, int dayofmonth) { // } }, startdate.getyear(), startdate.getmonth() - 1, startdate.getday() );
now want change text of buttons. try following code:
dialog.setbutton(datepickerdialog.button_positive, "new label", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { // } });
now problem date datepicker control. datesetlistener not called click on button. how possible date via datesetlistener? possibility date about
public void onclick(dialoginterface dialog, int which) { int year = ((datepickerdialog) dialog).getdatepicker().getyear(); int month = ((datepickerdialog) dialog).getdatepicker().getmonth(); int day = ((datepickerdialog) dialog).getdatepicker().getdayofmonth(); }
but seems unnecessary complicated way.
for timepickerdialog alternative way not work because find no way timepicker control. therefore need use timesetlistener cannot find possibility (like datepicker).
thanks response.
i supose work on datepicker, works me in timepicker:
the listener:
timepickerdialog.ontimesetlistener mtimesetlistenerini = new timepickerdialog.ontimesetlistener() { @override public void ontimeset(android.widget.timepicker view, int hourofday, int minute) { log.i("","initial: "+hourofday+":"+minute); } }; timepickerdialog yourfragment = new timepickerdialog(this, mtimesetlistenerini, hour, minute, true); yourfragment.setbutton(dialoginterface.button_positive, "ok", yourfragment); yourfragment.setbutton(dialoginterface.button_negative, "cancel", yourfragment);
Comments
Post a Comment