Im looking for the difference in using list adapter and recycleview adapter in android. Any different about performance, pros and cons in using them.
After that generally, we provide a way to set data to adapter by adding a method like setList () and then in the method we assign a new list and then we call notifyDataSetChanged () to update RecyclerView. But that’s not it. The method notifyDataSetChanged () refreshes whole list.
The ViewHolder pattern is entirely optional in ListView, but it’s baked into RecyclerView. ListView only supports vertical scrolling, but RecyclerView isn’t limited to vertically scrolling lists. Show activity on this post.
ListAdapter gets data using a method called submitList (), which submits a list to be diffed against the current list and displayed. This means you no longer have to override getItemCount () because ListAdapter manages the list. In the Activity class, call submitList () on the Adapter and pass in the data list.
For example the RecyclerView list by default has no dividers between rows — it’s consistent with the Material Design guidelines. However if we want to add divider for some reason, we can use DividerItemDecoration and add it to the RecyclerView.
ListAdapter
is just an extension of RecyclerView.Adapter
. Its computes diffs between Lists on a background thread with AsyncListDiff
.
You can obviously create a RecyclerView.Adapter
to work in same way . Its just ListAdapter
already works on this principal out of the box. It defines a contract to force DiffUtil
uses hence both of its constructor need a DiffChecker
.
Performance will be same if you use ListAdapter
or a RecyclerView.Adapter
with AsyncDiffChecker. Without async Diff checker ListAdapter's
performance will be better.
Recyclerview.Adapter
ListAdapter
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