Overridden DialogFragment Method onCreateDialog

Method onCreateDialog (Fig. 7.35) inflates the custom View (lines 32–34) defined by fragment_color.xml containing the GUI for selecting a color, then attaches that View to the AlertDialog by calling AlertDialog.Builder’s setView method (line 35). Lines 42–50 get references to the dialog’s SeekBars and colorView. Next, lines 53–56 register colorChangedListener (Fig. 7.38) as the listener for the SeekBars’ events.

26      // create an AlertDialog and return it27      @Override28      public Dialog onCreateDialog(Bundle bundle)29      {30         AlertDialog.Builder builder =31            new AlertDialog.Builder(getActivity());32         View colorDialogView =                                 ...

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.