4.5.10. deleteSearch Method

The event handler in Fig. 4.25 calls method deleteSearch (Figure 4.27) when the user long presses a search tag and selects Delete. Before deleting the search, the app displays an AlertDialog to confirm the delete operation. Lines 241–242 set the dialog’s title to a formatted String in which tag replaces the format specifier in the String resource R.string.confirmMessage ("Are you sure you want to delete the search \"%s\"?"). Lines 245–254 configure the dialog’s negative button to dismiss the dialog. The String resource R.string.cancel represents "Cancel". Lines 257–275 configure the dialog’s positive button to remove the search. The String resource R.string.delete represents "Delete". Line 263 removes the tag from ...

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.