It may seem odd to have a separate chapter for the
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
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
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
RecyclerView is a modern reinterpretation of the classical
ListView. You want to learn when and how to use the new paradigm.
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 ...