Method onCreateDialog
Method onCreateDialog
(lines 25–61) inflates the custom View
(lines 30–31) defined by fragment_line_width.xml
that displays the GUI for selecting the line width, then attaches that View
to the AlertDialog
by calling AlertDialog.Builder
’s setView
method (line 32). Lines 39–40 get a reference to the ImageView
in which the sample line will be drawn. Next, lines 43–47 get a reference to the widthSeekBar
, register lineWidthChanged
(lines 93–127) as the SeekBar
’s listener and set the SeekBar
’s current value to the current line width. Lines 50–58 define the dialog’s positive button to call the DoodleView
’s setLineWidth
method when the user touches the Set Line Width button. Line 60 returns the AlertDialog
for display.
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.