Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Monday, December 28, 2015

RecyclerView vs. ListView

RecyclerView vs. ListView


From android developer :

The RecyclerView widget is a more advanced and flexible version of ListView.

Okay, it sounds cool. But i really confuse about their difference when i saw an example picture :

enter image description here

The picture above can be easily created by ListView with custom adapter.

So, what do you think about this? What is the situation that fit best with RecyclerView?

Answer by CaptRespect for RecyclerView vs. 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.

Answer by daneejela for RecyclerView vs. ListView


Android created RecycleView as a ListView improvement, so yes, you could create attached list with ListView control, but using RecyclerView makes easier to:

1.) Reuse 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.

2.) Decouple list from its container - so you can put list items easily at run time in the different containers (linearLayout, gridLayout) with setting LayoutManager

EDIT- For example:

mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);  mRecyclerView.setLayoutManager(new LinearLayoutManager(this));  //or  mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));*  

3.) Animate common list actions - Animations are decoupled and delegated to ItemAnimator.

There is more about RecycleView but I think those are the main points.

So, to conclude RecycleView is more flexible control for handling "list data" that follows patterns of delegation of concerns and leaves for itself only one task - recycling items.

Answer by IntelliJ Amiya for RecyclerView vs. ListView


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 of ListView and GridView, and it can be found in the latest support-v7 version. The RecyclerView 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. This is Android, so things are never easy.

 compile 'com.android.support:recyclerview-v7:21.0.3'  

Or

compile 'com.android.support:recyclerview-v7:22.2.0'  

RecyclerView is indeed a powerful view than ListView . For more details you can visit This page.

Answer by Jim Baca for RecyclerView vs. ListView


ListView is the ancestor to RecyclerView. There were many things that ListView either didn't do, or didn't do well. If you were to gather the shortcomings of the listview and solved the problem by abstracting the problems into different domains you'd end up with something like the recycler view. Here are the main problem points with ListViews:

  • Didn't enforce View Reuse for same item types(Look at one of the adapters that are used in a list view, if you study the getView method you will see that nothing prevents a programmer from creating a new view for every row even if one is passed in via the convertView variable)

  • Didn't prevent costly findViewById uses(Even if you were recycling views as noted above it was possible for devs to be calling findViewById to update the displayed contents of child views. The main purpose of the ViewHolder pattern in ListViews was to cache the findViewById calls. However this was only available if you knew about it as it wasn't part of the platform at all)

  • Only supported Vertical Scrolling with Row displayed Views(Recycler view doesn't care about where views are placed and how they are moved, it's abstracted into a LayoutManager. A Recycler can therefor support the traditional ListView as shown above, as well as things like the GridView, but it isn't limited to that, it can do more, but you have to do the programming foot work to make it happen).

  • Animations to added/removed was not a use case that was considered. It was completely up to you to figure out how go about this.(Compare the RecyclerView.Adapter classes notify* method offerings v. ListViews to get an idea)

In short RecyclerView is a more flexible take on the ListView, albeit more coding may need to be done on your part.

Answer by Mohammed Imran N for RecyclerView vs. ListView


Major Advantage :

ViewHolder is not available by default in ListView. We will be creating explicitly inside the getView() RecyclerView has inbuilt Viewholder.

Answer by aimiliano for RecyclerView vs. ListView


In my opinion Recycler View was made to address the problem with the recycle pattern used in listviews because it was making developer's life more difficult. All the other you could handle more or less. For instance i use the same adapter for listview and gridview it doesnt matter in both views the getview ,getitemcount, gettypecount is used so its the same. Recycler View isn't needed if listview with listadapter or gridview with grid adapters is already working for you. If you have implemented correctly the ViewHolder Patttern in your listviews then you won't see any big improvement over RecycleView.

Answer by Meet Vora for RecyclerView vs. ListView


It is easier to implement the horizontal scrolling facility in RecyclerView as compared to ListView.


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.