This is the second article from our series which points out the most crucial parts in the beginning of Android development, step by step. Let’s focus on creating lists!
This is the whole list of topics that I would like to touch:
- Interacting with the UI
- Creating lists
- Creating custom views
- Taking pictures
- Downloading data
- Storing data
- Making it delightful with Material Design
In the previous article, we learned how to create simple UI components like TextViews or Buttons. However, to create a list, we have to do more than just find an ID of a view. It’s worth knowing how to implement it because we’ll need it on a daily basis.
ListView and RecyclerView
In Android, we have two ways of implementing a list — ListView and RecyclerView. The first one is a good old UI component, which has been included in the Android SDK since the very beginning. I used it a lot of times when an app needed a scrolling list.
The RecyclerView, however, was announced with Android Lollipop. It’s a kind of ListView2 but the name isn’t accidental. RecyclerView introduces a few more components that we should use, but it’s not a big deal – the responsibilities are split, so it’s a good change.
Generally, it’s better to use RecyclerView when it’s possible. But to understand why it’s worth doing this, we first need to implement lists using both ways. Let’s start with ListView.
Both implementations are separated into different posts, as well as the final comparison of the two. Thanks to this, if you aren’t interested in the ListView, you can jump straight to the RecyclerView without endless scrolling. However, I encourage you to read all of three articles.
Thanks to these three articles, we’ve learned how to implement a ListView, a RecyclerView and what’s the difference between them.
Generally, the main point of this is to know why we should use the RecyclerView instead of the ListView, if we are able to do so, in our project. A lot of ListView’s disadvantages were improved or solved with answers implemented in the RecyclerView, so even if we think about the RecyclerView as too complicated, we should give it a chance. Implement it a couple of times and – believe me – it’ll turn out to be very easy. The next step will be about custom views. Stay tuned!
The post was written by Mateusz Budzar, Droids On Roids Android Developer. This and other articles of Mateusz you can find also on Medium