Change DatePickerDialog's button texts
16,836
setButton ist the correct approach. As listener just pass the dialog object itself, because the onDateSetListener
gets passed with the constructor of the dialog.
DatePickerDialog dpd = new DatePickerDialog(this, mDateSetListener, mYear_g, mMonth_g, mDay_g);
dpd.setButton(DatePickerDialog.BUTTON_POSITIVE, "Button Text", dpd);
Related videos on Youtube
Author by
MatF
Updated on May 14, 2020Comments
-
MatF about 4 years
I'm having some trouble changing the text of the buttons of the dialog.
I tried to use:
setButton(int whichButton, CharSequence text, DialogInterface.OnClickListener listener)
and
setButton(int whichButton, CharSequence text, Message msg)
But I could not figure out what to put as the third parameter. I could pass a new
OnClickListener
, but I would like to use the callbackDatePickerDialog.OnDateSetListener
.I guess when I set a new
Listener
to theButton
theDateSetListener
won't ne called anymore? -
Mertuarez over 11 yearsdpd.setButton(DatePickerDialog.BUTTON_NEGATIVE, "Button Text", (OnClickListener)null);