4.5.8. Anonymous Inner Class That Implements the ListView’s OnItemLongClickListener to Share, Edit or Delete a Search

Figure 4.25 declares and initializes instance variable itemLongClickListener, which refers to an anonymous inner-class object that implements interface OnItemLongClickListener. Line 70 (Fig. 4.20) registered itemLongClickListener as the ListView’s event handler that responds when the user long presses an item in the ListView. Lines 153–210 override interface OnItemLongClickListener’s onItemLongClick method.

148      // itemLongClickListener displays a dialog allowing the user to delete149      // or edit a saved search150      OnItemLongClickListener itemLongClickListener =151         new OnItemLongClickListener() ...

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.