Reputation: 3178
Is there any advantages of converting the existing Listview in my app to RecyclerView?? Also when should I be using RecyclerView??
Upvotes: 15
Views: 4115
Reputation: 364928
The RecyclerView will be the future, and it is more than a ListView2 and the @reVeres's answer explain well the case.
It is the time to check the documentation and to do a little test, but it is not the time to switch, because the RecyclerView is the support-v21 and you can't use it in a production release.
Upvotes: 1
Reputation: 35264
That's a tough question to answer. First of all: Think of the RecyclerView
as the successor of the AdapterViews
which comes with alot of useful improvement especially in the fields of animations for each item. Actually that's also what the Docs say:
RecyclerView is a more advanced and flexible version of ListView. This widget is a container for large sets of views that can be recycled and scrolled very efficiently. Use the RecyclerView widget when you have lists with elements that change dynamically.
You also have the flexibility to define custom layout managers and animations for this widget.
So in the future we'll probably don't use ListViews
anymore. Furthermore the RecyclerView doesn't need anything like "notifyDataSetChanged()"
when an item is added or deleted from your List, which is a huge improvement performance-wise.
If you wanna know more what Google means by saying "more advanced and flexible version of ListView" I'd recommend you to read this Blog-Post A First Glance at Android’s RecyclerView.
But to answer your questions explicity:
Is there any advantages of converting the existing Listview in my app to RecyclerView?
Yes. As already said the RecyclerView is much more flexible and comes with handy animations at no cost. (In terms of doing this on your own)
When should I be using RecyclerView?
Everywhere where a ListView is appropriate a RecyclerView is as well.
And an additional question:
Is it necessary to switch from ListView to RecyclerView?
At the moment absolutely not! You have to consider that the RecyclerView isn't final at this point. So there may be some changes, bug-fixes and new features in the near future.
(As an example for a bug: clipToPadding
doesn't work atm. Luckily it has been reported already)
Upvotes: 17