Change DatePickerDialog's button texts

假如想象 提交于 2019-12-06 16:50:56

问题


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 callback DatePickerDialog.OnDateSetListener.

I guess when I set a new Listener to the Button the DateSetListener won't ne called anymore?


回答1:


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);


来源:https://stackoverflow.com/questions/6218069/change-datepickerdialogs-button-texts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!