Hi,
I'm using a datepicker in Android to let the user to choose the date. I want it to do one thing if the user picks a date and sets it (I have that working fine) and then to clear a certain text field if the user pushes the cancel button on the datepicker (open up the datepicker but then cancel out of it).
The way I've been trying is by making a
private DatePickerDialog.OnCancelListener mDateCancelListener =
new DatePickerDialog.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
timeClear(); //method that clears text field
}
};
then I do
TimePickerDialog timeDialog = new TimePickerDialog(this,
mTimeSetListener,
c.get(Calendar.HOUR),
c.get(Calendar.MINUTE),
false);
timeDialog.setOnCancelListener(mTimeCancelListener);
to attach the listener.
My problem is that the listener works if the user pushes the back button, but not if they push the cancel button. I tried using a dismiss listener, and that works, except for the fact that it goes off even whether I set or cancel the datepicker!
What do I need to do so something goes off if and only if I push the cancel button on my datepicker?