Android – Difference Between RecyclerView and ListView
In Android View is a basic building block of UI (User Interface). A view is a small rectangular box that responds to user inputs. RecyclerView and ListView are the two major Views in Android. So in this article, we are going to see the major differences between these two views.
RecyclerView is a ViewGroup added to the android studio as a successor of the GridView and ListView. It is an improvement on both of them and can be found in the latest v-7 support packages. It has been created to make possible the construction of any lists with XML layouts as an item that can be customized vastly while improving on the efficiency of ListViews and GridViews. This improvement is achieved by recycling the views which are out of the visibility of the user. For example, if a user scrolled down to a position where items 4 and 5 are visible; items 1, 2, and 3 would be cleared from the memory to reduce memory consumption.
To read more on RecyclerView refer to this article: RecyclerView in Android with Example
A ListView is a type of AdapterView that displays a vertical list of scroll-able views and each view is placed one below the other. Using the Adapter, items are inserted into the list from an array or database. For displaying the items in the list method setAdaptor() is used. setAdaptor() method conjoins an adapter with the list. Android ListView is a ViewGroup that is used to display the list of items in multiple rows and contains an adapter that automatically inserts the items into the list.
To read more on ListView refer to this article: Android Listview in Java with Example
|The RecyclerView’s adaptor forces us to use the ViewHolder pattern. The views are split into onCreateViewholder() and onBindViewholder() methods.||The ListView doesn’t give that kind of protection by default, so without implementing the ViewHolder pattern inside the getView().|
|Efficient Scrolling, we can choose the way of scroll-like vertically or horizontally and grids.||Inefficient scrolling, we can only create vertical scrolling.|
|Use of less memory.||More memory is used for a long list. Sometimes devices get hanged.|
|Animations using ItemAnimator are easy and smooth. Animations like list appearance and disappearance, adding or removing particular views, and so on.||It’s complex to use Animation and hard to handle it.|
|Dividers between items are not shown by default.||Dividers between items are shown by default.|
|Use ItemDecorations to add margins and draw on or under an item View.||ItemDecorations require customization.|
Please Login to comment...