Differences between ReciclerView and ListView

1

I am developing a app in android . I have integrated the sdk de twitter , and it offers me 2 options to show a timeline, by ReciclerView or by ListView .

  

The problem is that I do not know what is the difference between both and what is   more efficient or more appropriate to use. Or in what circumstances to use one or the other.

    
asked by Alberto Mier 27.03.2018 в 11:15
source

2 answers

1

The main advantage of RecyclerView over ListView is that it is much more efficient when it comes to displaying a large amount of data. That's because "recycle" the views that are not on screen to load new data in them when you do scroll .

Apart from that it is more flexible, it offers effects and allows you to touch more the design of the elements and the list itself, it is easier to manage the click on elements ...

The disadvantage is that, at the beginning, it is something more complex to implement (partly because of the viewholder pattern), but once you understand what each thing is, you will prefer it.

Especially if you are starting, try the two options, load a lot of data and try the lag theme in the scroll.

    
answered by 27.03.2018 в 11:46
1

The RecyclerView widget is a more flexible and advanced version of ListView . This widget is a container for displaying large data sets that can be moved very efficiently by maintaining a limited number of views. Use the widget RecyclerView when you have datasets whose elements change at runtime based on user action or network events.

The RecyclerView class simplifies the screen and manipulation of large sets of data by providing the following:

  
  • Design managers for the positioning of elements.
  •   
  • Default animations for common operations with elements, such as removing or adding elements.
  •   

You also have the flexibility to define custom design managers and animations for widgets RecyclerView .

Taken from the Android documentation

The RecyclerView class simplifies the screen and manipulation of large sets of data by providing the following:

Design managers for positioning elements Default animations for common operations with elements, such as removing or adding elements You also have the flexibility to define custom design managers and animations for RecyclerView widgets.

RecyclerView was created as an improvement of ListView , so yes, you can create an attached list with control ListView , but use RecyclerView is easier because:

  
  • Reuse the cells while moving up / down; this is possible by implementing View Holder in the listView adapter, but   it was an optional thing, while in RecycleView it's the way   default to write the adapter.

  •   
  • Decouples the list from its container, so you can easily list items at run time in the different   containers (linearLayout, gridLayout) with the configuration of   LayoutManager.

  •   

Example:

mRecyclerView = (RecyclerView) findViewById(R.id.my_recycler_view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
//or
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2));
  
  • Anima common list actions: animations are undocked and delegated to ItemAnimator.
  •   

There's more about RecyclerView , but I think these are the main points .

So, to conclude, RecyclerView is one more control Flexible to handle the "list data" that follows the patterns of delegation of concerns and leaves for itself only one task: to recycle elements.

Taken from the @daneejela's response

    
answered by 27.03.2018 в 17:16