Introduction
In the previous chapter, we learned how to fetch data, including lists of items and image URLs, from APIs, and how to load images from URLs. Combining that knowledge with the ability to display lists of items is the goal of this chapter.
Quite often, you will want to present your users with a list of items. For example, you might want to show them a list of pictures on their device, or let them select their country from a list of all countries. To do that, you would need to populate multiple views, all sharing the same layout but presenting different content.
Historically, this was achieved by using ListView
or GridView
. While both are still viable options, they do not offer the robustness and flexibility of RecyclerView
. For example, they do not support large datasets well, they do not support horizontal scrolling, and they do not offer rich divider customization. Customizing the divider between items in RecyclerView
can be easily achieved using RecyclerView.ItemDecorator...