From android developer (Creating Lists and Cards):
<The RecyclerView widget is a more advanced and flexible version of ListView.
For list views to have good performance you'll need to implement the holder pattern, and that's easy to mess up especially when you want to populate the list with several different kinds of views.
The RecyclerView bakes this pattern in, making it more difficult to mess up. It's also more flexible, making it easier to handle different layouts, that aren't straight linear, like a grid.
The
RecyclerView
is a new ViewGroup that is prepared to render any adapter-based view in a similar way. It is supossed to be the successor ofListView and GridView
, and it can be found in thelatest support-v7 version
. TheRecyclerView
has been developed with extensibility in mind, so it is possible to create any kind of layout you can think of, but not without a little pain-in-the-ass dose.
Answer taken from Antonio leiva
compile 'com.android.support:recyclerview-v7:27.0.0'
RecyclerView
is indeed a powerful view
than ListView
.
For more details you can visit This page.
RecyclerView
was created as a ListView
improvement, so yes, you can create an attached list with ListView
control, but using RecyclerView
is easier as it:
Reuses cells while scrolling up/down - this is possible with implementing View Holder in the ListView
adapter, but it was an optional thing, while in the RecycleView
it's the default way of writing adapter.
Decouples list from its container - so you can put list items easily at run time in the different containers (linearLayout, gridLayout) with setting LayoutManager
.
Example:
mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
//or
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
ItemAnimator
. There is more about RecyclerView
, but I think these points are the main ones.
So, to conclude, RecyclerView
is a more flexible control for handling "list data" that follows patterns of delegation of concerns and leaves for itself only one task - recycling items.
There are many differences between ListView and RecyclerView, but you should be aware of the following in particular:
I think the main and biggest difference they have is that ListView
looks for the position of the item while creating or putting it, on the other hand RecyclerView
looks for the type of the item. if there is another item created with the same type RecyclerView
does not create it again. It asks first adapter and then asks to recycledpool, if recycled pool says "yeah I've created a type similar to it", then RecyclerView
doesn't try to create same type. ListView
doesn't have a this kind of pooling mechanism.
RecyclerView info
The RecyclerView
was introduced with Android 5.0 (Lollipop)
. it is included in the Support Library. Thus, it is compatible with Android API Level 7.
Similarly to the ListView
, RecyclerView’s
main idea is to provide listing functionality in a performance friendly manner. The ‘Recycler’ part of this view’s name is not there by coincidence. The RecyclerView
can actually recycle the items with which it’s currently working. The recycling process is done thanks to a pattern called View Holder.
Pros & Cons of RecyclerView
Pros:
Cons:
ListView info
The ListView
has been around since the very beginning of Android. It was available even in API Level 1
and it has the same purpose as the RecyclerView
.
The usage of the ListView is actually really simple. In this aspect, it’s not like its successor. The learning curve is smoother than the one for the RecyclerView. Thus, it is easier to grasp. We don’t have to deal with things like the LayoutManager, ItemAnimator or DiffUtil.
Pros & Cons of ListView
Pros:
ExpandableListView
Cons: