Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I change the existing Listview in my app to RecyclerView?

Is there any advantages of converting the existing Listview in my app to RecyclerView?? Also when should I be using RecyclerView??

like image 713
T_C Avatar asked Sep 14 '14 05:09

T_C


People also ask

Should I use list view or 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.

Why is a RecyclerView better than a ListView?

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.

What is the advantage of using RecyclerView over list view in android?

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.


2 Answers

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)

like image 79
reVerse Avatar answered Oct 20 '22 14:10

reVerse


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.

like image 34
Gabriele Mariotti Avatar answered Oct 20 '22 13:10

Gabriele Mariotti