Creating a DialogFragment
For CriminalIntent, you are going to create a DialogFragment subclass named DatePickerFragment.
Within DatePickerFragment, you will create and configure an instance of AlertDialog that displays a
DatePicker widget. DatePickerFragment will be hosted by CrimePagerActivity.
Figure 12.3 shows you an overview of these relationships.
Figure 12.3 Object diagram for two fragments hosted by CrimePagerActivity
Your first tasks are:
- creating the DatePickerFragment class
- building an AlertDialog
- getting the dialog onscreen via the FragmentManager
Later in the chapter, you will wire up the DatePicker and pass the necessary data between
CrimeFragment and DatePickerFragment.
Before you get started, add the string resource shown in Listing 12.1.
Listing 12.1 Adding string for dialog title (values/strings.xml)
...