ListView v. RecyclerView

I came across a post on StackOverflow asking what the difference is between a ListView and a Recycler view, especially in the context of the screen shot that the user posted of the recycler view, there was no immediate distinguishable difference.

ListView is the ancestor to RecyclerView. There were many things that ListView either didn’t do, or didn’t do well. If you were to gather the shortcomings of the listview and solved the problem by abstracting the problems into different domains you’d end up with something like the recycler view. Here are the main problem points with ListViews:

– Didn’t enforce View Reuse for same item types(Look at one of the adapters that are used in a list view, if you study the getView method you will see that nothing prevents a programmer from creating a new view for every row even if one is passed in via the convertView variable)

– Didn’t prevent costly findViewById uses(Even if you were recycling views as noted above it was possible for devs to be calling findViewById to update the displayed contents of child views. The main purpose of the ViewHolder pattern in ListViews was to cache the findViewById calls. However this was only available if you knew about it as it wasn’t part of the platform at all)

– Only supported Vertical Scrolling with Row displayed Views(Recycler view doesn’t care about where views are placed and how they are moved, it’s abstracted into a LayoutManager. A Recycler can therefor support the traditional ListView as shown above, as well as things like the GridView, but it isn’t limited to that, it can do more, but you have to do the programming foot work to make it happen).

– Animations to added/removed was not a use case that was considered. It was completely up to you to figure out how go about this.(Compare the RecyclerView.Adapter classes notify* method offerings v. ListViews to get an idea)

In short RecyclerView is a more flexible take on the ListView, albeit more coding may need to be done on your part.

Leave a Reply

Your email address will not be published. Required fields are marked *