Can I change the label of the “set” button in a TimePickerDialog?

霸气de小男生 提交于 2019-12-13 15:31:37

问题


By default you have "set" and "cancel", I would like to change the "set" label to "Find".

Is it possible?


回答1:


Try

yourTimePickerDialog.setButton(BUTTON_POSITIVE, "Find", yourTimePickerDialog);



回答2:


TimePickerDialog tp = new TimePickerDialog(this, mTimeSetListener, 0, 0, false);
tp.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which)
    {
        if (which == DialogInterface.BUTTON_POSITIVE)
        {
        }
    }
});
tp.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which)
    {
        if (which == DialogInterface.BUTTON_NEGATIVE)
        {

        }
    }
});

try using the above code..




回答3:


Better create a xml file with time picker and two buttons as you need.

Then you can manually launch a alert dialog with view set to this xml file.

You can set the text as you want to both the buttons also you can manually handle the click events for both the buttons.



来源:https://stackoverflow.com/questions/10284165/can-i-change-the-label-of-the-set-button-in-a-timepickerdialog

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