5.11 EraseImageDialogFragment
Class
Class EraseImageDialogFragment
(Fig. 5.49) extends DialogFragment
to create an AlertDialog
that confirms whether the user really wants to erase the entire image. The class is similar to class ColorDialogFragment
and LineWidthDialogFragment
, so we discuss only method onCreateDialog
(lines 15–35) here. The method creates an AlertDialog
with Erase Image and Cancel button. Lines 24–30 configure the Erase Image button as the positive button—when the user touches this, line 27 in the button’s listener calls the DoodleView
’s clear
method to erase the image. Line 33 configures Cancel as the negative button—when the user touches this, the dialog is dismissed. In this case, we use the predefined Android String
resource ...
Get Android How to Program, 3/e 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.