RecyclerView, Adapter, and ViewHolder
Now, you want CrimeListFragment to display a list of crimes to the user. To do this, you will use a RecyclerView.
RecyclerView is a subclass of ViewGroup. It displays a list of child View objects, one for each item in your list of items. Depending on the complexity of what you need to display, these child Views can be complex or very simple.
For your first implementation, each item in the list will display the title and date of a Crime. The View object on each row will be a LinearLayout containing two TextViews, as shown in Figure 8.4.
Figure 8.4 A RecyclerView
with child View
s
Get Android Programming: The Big Nerd Ranch Guide, Third 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.