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(
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);
}
}
});