4.5.5. Anonymous Inner Class That Implements the saveButton’s OnClickListener to Save a New or Updated Search

Figure 4.21 declares and initializes instance variable saveButtonListener, which refers to an anonymous inner class object that implements interface OnClickListener. Line 64 (Fig. 4.20) registered saveButtonListener as saveButtons’s event handler. Lines 76–109 override interface OnClickListener’s onClick method. If the user entered a query and a tag (lines 80–81), lines 83–84 call method addTaggedSearch (Fig. 4.23) to store the tag–query pair and lines 85–86 clear the two EditTexts. Lines 88–90 hide the soft keyboard.

Configuring an AlertDialog

If the user did not enter a query and a tag, lines 92–108 display an AlertDialog indicating ...

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.