

Previously, with the use of the ListView, we were only able to create a vertical-scrolling list, so it wasn’t that flexible. For grids, it is more suitable to choose the GridLayoutManager. For example, if we want to scroll our list vertically or horizontally, we can choose LinearLayoutManager. This class gives us the opportunity to choose the way that we want to show the row views and how to scroll the list. Thanks to this, RecyclerView doesn’t have to think about how to position the row view. The LayoutManager takes responsibility for layouting row views. The ListView, on the other hand, doesn’t give us that kind of protection by default, so without implementing the ViewHolder pattern inside the getView() method, we’ll end with inefficient scrolling in our list. The creating part (inflating the layout and finding views) and updating the views is split into two methods - onCreateViewHolder() and onBindViewHolder(). The RecyclerView’s adapter forces us to use the ViewHolder pattern. It stores list row views references and, thanks to this, calling the findViewById() method only occurs a couple of times, rather than for the entire dataset and on each bind view. The ViewHolder pattern allows us to make our list scrolling act smoothly. These are some crucial differences between ListView and RecyclerView:


It’s more efficient by default, the layout is separated and we have more possibilities over the data set inside the adapter. Whenever we have to handle the list, such as to configure it in some way, the only way to do this is through the ListView object or inside the adapter.Ī lot of bad things in the ListView were fixed or changed in the RecyclerView. ListView is a bit heavy and it has a lot of responsibilities. There are some differences between these two views.
