1. If you DON'T care about loosing the title on your dialog:
If you are strictly following the official documentation on Pickers, here is what you have to do in your onCreateDialog()
method:
Instead of creating new instance of TimePickerDialog
and returning it straight away, call setTitle(null)
on it before you return it, like so:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
/* ... */
Dialog dialogFragment = new TimePickerDialog(/* ... */);
dialogFragment.setTitle(null);
return dialogFragment;
}
I would like to note, that the problem was not occurring on Android 5.0.2 (Lollipop). The dialog was without the title by default.
The problem occurred on Android 6.0 device. It displayed the very same dialog with a title.
2. If having the title on the dialog is a must for you:
You should read the source code for TimePickerDialog. No other way around.
I didn't go full rage-mode on the source code, since I had the luxury of just setting it to null
.
I believe you can find a private method setupTitle()
of the package-private class AlertController very interesting. AlertControler
is used in AlertDialog business logic.