Recyclerview vs Listview android


With Android Lollipop, the RecyclerView made its way. RecyclerView is more powerful, flexible over ListView. The advantages with the RecyclerView are given below:

ViewHolder Pattern is compulsory:

In a ListView, it was recommended to use the ViewHolder pattern but it was never a compulsion. In case of RecyclerView, it is mandatory to use RecyclerView.ViewHolder class.

RecyclerView can do much more:

In a ListView,  the items were placed one below the other. There is no way to even implement a horizontal ListView.

Using RecyclerView we can have

1) LinearLayoutManager - which supports both vertical and horizontal lists,

2) StaggeredLayoutManager - which supports Pinterest like staggered lists,

3) GridLayoutManager - which supports displaying grids as seen in Gallery apps.

we can put list items at run time in the different containers (linearLayout, gridLayout) with setting LayoutManager.
Example : RecyclerView.setLayoutManager(new LinearLayoutManager(this));

Animate every item:

ListViews does not support decent animations. Using the RecyclerView.ItemAnimator class animating the views is very easy and intuitive.

Decorate the items:

In case of ListViews, dynamically decorating items like adding borders or dividers would take a lot of time. But for RecyclerView, the RecyclerView.ItemDecorator class gives huge control to the developers to put styles like borders, dividers and much more.

RecyclerView.OnItemTouchListener:

RecyclerView.OnItemTouchListener is much more powerful than AdapterView.OnItemClickListener but it is a bit complicated for the developers.


Anand S Joshi

Project Manager
Nanite Solutions
nanitesol.com

Comments

Popular Posts