Android Programming: The Big Nerd Ranch Guide, 5th Edition
by Bryan Sills, Brian Gardner, Kristin Marsicano, Chris Stewart
Creating a DialogFragment
When displaying a DatePickerDialog, it is a good idea to wrap it in an instance of DialogFragment, a subclass of Fragment. It is possible to display a DatePickerDialog without a DialogFragment, but it is not recommended. Having the DatePickerDialog managed by the FragmentManager gives you more options for presenting the dialog.
In addition, a bare DatePickerDialog will vanish if the device is rotated. If the DatePickerDialog is wrapped in a fragment, then the dialog will be re-created and put back onscreen after rotation.
For CriminalIntent, you are going to create a DialogFragment subclass named DatePickerFragment. Within DatePickerFragment, you will create and configure an instance of DatePickerDialog ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access