I have a TimePickerDialog preference with a "TimePreference" class which extends DialogPreference:
public class TimePreference extends DialogPreference{
...
private TimePicker picker=null;
...
public TimePreference(Context ctxt, AttributeSet attrs){
super(ctxt, attrs);
setPositiveButtonText(android.R.string.ok);
setNegativeButtonText(android.R.string.cancel);
}
@Override
protected View onCreateDialogView(){
picker=new TimePicker(getContext());
return(picker);
}
...
}
I would like to add a third button, which will set the preference to the current time and close the dialog, like this:
The question is, is there some way of doing this using TimePickers or should I make a custom AlertDialog?
Thanks for your answers! I will show you how I finally managed it, just in case someone wants to do the same.
First, I have a layout file good_timedialog.xml which looks like I wanted:
Then I have a TimePreference class:
And at the perferences.xml file, I can use
<com.example.TimePreference android:key="test"/>