Anonymous Inner Class That Implements Interface OnSeekBarChangeListener to Respond to the Events of the Alpha, Red, Green and Blue SeekBars

Figure 7.38 defines an anonymous inner class that implements interface OnSeekBarChangeListener to respond to events when the user adjusts the SeekBars in the Choose Color Dialog. This was registered as the SeekBars’ event handler in Fig. 7.35 (lines 53–56). Method onProgressChanged (lines 115–123) is called when the position of a SeekBar’s thumb changes. If the user moved a SeekBar’s thumb (line 118), lines 119–121 store the new color. Class Color’s static method argb combines the SeekBars’ values into a Color and returns the appropriate color as an int. We then use class View’s setBackgroundColor method ...

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.