From android developer (Creating Lists and Cards):
The RecyclerView widget is a more advanced and flexible version of
ListView.
Okay, it sounds cool, but when I saw this example picture, I got really confused about the difference between these two.
The picture above can be easily created by ListView
using custom adapter.
So, in what situation should one use RecyclerView
?
Best Answer
RecyclerView
was created as aListView
improvement, so yes, you can create an attached list withListView
control, but usingRecyclerView
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 theRecycleView
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:
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.