O'Reilly logo

Android Programming: The Big Nerd Ranch Guide, Third Edition by Kristin Marsicano, Chris Stewart, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 Views

Figure shows A RecyclerView with child Views. Screen shows a list of crimes, each separated by dotted rectangles. A pointer points to these rectangles and rads, recycler views. The view is placed at the right of the screen.

Figure 8.4 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required