Chapter 12 Dialogs
Run CriminalIntent and press the date button to see the dialog (Figure 12.4).
Figure 12.4 An AlertDialog with a title and a button
Setting a dialog’s contents
Next, you are going to add a DatePicker widget to your AlertDialog using the following
AlertDialog.Builder method:
public AlertDialog.Builder setView(View view)
This method configures the dialog to display the passed-in View object between the dialog’s title and its
button(s).
In the project tool window, create a new layout resource file named dialog_date.xml and make its
root element DatePicker. This layout will consist of a single View object – a DatePicker – that you
will inflate and pass into setView(...).
Configure the DatePicker as shown in Figure 12.5.
Figure 12.5 DatePicker layout (layout/dialog_date.xml)