7.9. EraseImageDialogFragment Class
Class EraseImageDialogFragment
(Fig. 7.40) 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 16–41) here. The method creates an AlertDialog
with Erase Image and Cancel button. Lines 27–35 configure the Erase Image button as the positive button—when the user touches this, line 32 in the button’s listener calls the DoodleView
’s clear
method to erase the image. Line 38 configures Cancel as the negative button—when the user touches this, the dialog is dismissed. Line 40 returns the AlertDialog
.
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.