Is there any advantages of converting the existing Listview in my app to RecyclerView?? Also when should I be using RecyclerView??
Simple answer: You should use RecyclerView in a situation where you want to show a lot of items, and the number of them is dynamic. ListView should only be used when the number of items is always the same and is limited to the screen size.
RecyclerView has greater support for LayoutManagement including vertical lists, horizontal lists, grids and staggered grids. ListView only supports vertical lists. ListView starts by default with dividers between items and requires customisation to add decorations.
The major advantage of the usage of RecyclerView is the performance when loading list items in the list to the view. RecyclerView prepares the view behind and ahead beyond the visible entries. It gives significant performance when you need to fetch the bitmap image in your list from a background task.
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)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With