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.

Your first implementation of providing list items for display will be simple: a list item will only display the title of a Crime, and the View object will be a simple TextView, as shown in Figure 9.4.

Figure 9.4  A RecyclerView with child TextViews

Figure 9.4 shows 12 TextViews. Later you will be able to run CriminalIntent and swipe to scroll ...

Get Android Programming: The Big Nerd Ranch Guide, 2nd 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.