8.6 SearchesAdapter Subclass of RecyclerView.Adapter

This section presents the RecyclerView.Adapter that binds the items in MainActivity’s List<String> named tags to the app’s RecyclerView.

8.6.1 package Statement, import statements, Instance Variables and Constructor

Figure 8.25 shows the beginning of class SearchesAdapter’s definition. The class extends generic class RecyclerView.Adapter, using as its type argument the nested class SearchesAdapter.ViewHolder (defined in Section 8.6.2). The instance variables in lines 17–18 maintain references to the event listeners (defined in class MainActivity) that are registered for each RecyclerView item. The instance variable in line 21 maintains a reference to MainActivity’s List<String> that contains ...

Get Android How to Program, 3/e 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.