5.9 ColorDialogFragment Class

Class ColorDialogFragment (Figs. 5.435.47) extends DialogFragment to create an AlertDialog for setting the drawing color. The class’s instance variables (lines 18–23) are used to reference the GUI controls for selecting the new color, displaying a preview of it and storing the color as a 32-bit int value that represents the color’s ARGB values.

Fig. 5.43 ColorDialogFragment’s package statement, import statements and instance variables

Computer code has 122 lines.

Fig. 5.47 Anonymous inner class that implements interface OnSeekBarChangeListener to respond to the events of the alpha, red, green and blue SeekBar ...

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.