TimePickerDialog cancel button

前端 未结 6 1174
暗喜
暗喜 2021-01-06 07:30

I have an activity - TimePickerActivity - which creates a TimePickerDialog. I have a onTimeSetListener which responds to the Set button at the end of which it calls finish(

6条回答
  •  孤街浪徒
    2021-01-06 08:00

    here is how I did it:

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

提交回复
热议问题