我不确定如何为下面的代码实现 onCancel/onDismiss 侦听器。有人可以帮忙吗。
private TimePickerDialog.OnTimeSetListener mTimeSetListener =
new TimePickerDialog.OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
mHour = hourOfDay;
mMinute = minute;
time = ""+mHour+":"+mMinute;
notifications();
}
};
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case TIME_DIALOG_ID:
return new TimePickerDialog(this,
mTimeSetListener, mHour, mMinute, false);
}
return null;
}
编辑:工作代码如下。当您单击设置时,它就完成了。它删除了复选框的任何其他内容。
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case TIME_DIALOG_ID:
TimePickerDialog myTime = new TimePickerDialog(this,mTimeSetListener, mHour, mMinute, false);
myTime.setOnCancelListener(new OnCancelListener(){
CheckBox checkBox = (CheckBox) findViewById(R.id.checkBox1);
public void onCancel(DialogInterface dialog) {
Log.d("IN HERE","HERE2");
cbChecked = false;
notValue = 0;
checkBox.setChecked(false);
checkBox.setText("Use reminders");
}
});
return myTime;
}
return null;
}