O'Reilly logo

Android Cookbook, 2nd Edition by Ian F. Darwin

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

Chapter 8. Other GUI Elements: Lists and Views

It may seem odd to have a separate chapter for the RecyclerView and ListView components. But these are, in fact, among the most important GUI components, being used in probably 80% of all Android applications. And these list components are very flexible; you can do a lot with them, but figuring out how to do it is sometimes not as intuitive as it could be.

In this chapter we cover topics from basic RecyclerView and ListView uses through to advanced uses.

So why are there two list components? ListView has been around since the beginning of Android time. RecyclerView was introduced around 2015 as a more modern replacement, but many applications still use the original ListView, so we discuss both.

A good overview of ListView can be found in a Google I/O 2010 talk that’s available on Google’s YouTube channel; this was presented by Google employees Romain Guy and Adam Powell, who work on the code for ListView.

8.1 Building List-Based Applications with RecyclerView

Ian Darwin

Problem

RecyclerView is a modern reinterpretation of the classical ListView. You want to learn when and how to use the new paradigm.

Solution

Use a RecyclerView.

Discussion

You could argue that RecyclerView is badly named. It should have been called ListView2 or something similar, to tie it in to the ListView, which it aims to replace. Paraphrasing Dr. Seuss: “But they didn’t, and now it’s too late.” It’s called RecyclerView because it is better at recycling ...

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