android timepicker取消

时间:2011-03-01 23:06:03

标签: android dialog timepicker

我使用标准的android timepicker:

...
showDialog(TIMEPICKER);
...
private TimePickerDialog.OnTimeSetListener mTimeSetListener =
        new TimePickerDialog.OnTimeSetListener() {
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            //code;     
        }
    };


    @Override
    protected Dialog onCreateDialog(int id) {
    switch (id) {
    case TIMEPICKER:
    return new TimePickerDialog(this,mTimeSetListener, 0, 0, true);
    }
    return null;
    }

一切都很好,但是我怎样才能抓住取消按钮来执行一些代码?

1 个答案:

答案 0 :(得分:1)

setOnCancelListener或尝试使用setOnDismissListener。