4.5.7. Anonymous Inner Class That Implements the ListView’s OnItemClickListener to Display Search Results
Figure 4.24 declares and initializes instance variable itemClickListener
, which refers to an anonymous inner-class object that implements interface OnItemClickListener
. Line 67 (Fig. 4.20) registered itemClickListener
as the ListView
’s event handler that responds when the user touches an item in the ListView
. Lines 131–145 override interface OnItemClickListener
’s onItemClick
method. The method’s arguments are:
• The AdapterView
where the user touched an item. The ?
in AdapterView<?>
is a wildcard in Java generics indicating method onItemClick
can receive an AdapterView
that displays any type of data—in this case, a ListView<String>
.
• The ...
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.