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

2019-07-09 01:33发布

问题:

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.