33

Im looking for the difference in using list adapter and recycleview adapter in android. Any different about performance, pros and cons in using them.

2
  • blog.usejournal.com/… I think this one will solve your question. ListAdapter is designed to to solve the animation problem with DiffUtil.
    – Teo
    Mar 5, 2021 at 2:27
  • But i can customize more if i use recycle view adapter with DiffUtil so is there a case which we should choose list adapter Mar 5, 2021 at 4:31

3 Answers 3

47

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.

28

Recyclerview.Adapter

  • best if the list is static

ListAdapter

  • best if the list is dynamic
2
  • 1
    It would be better if you provide the example for both
    – Marfin. F
    Aug 2, 2022 at 3:19
  • 1
    For instance: if you update the item of list, if you delete or add items from list ListAdapter is the better option. If you only show data without updating it, Recyclerview.Adapter is the better option. Mar 22 at 11:56
6

List Adapter is extension of RecyclerView.Adapter for presenting List data in a RecyclerView, including computing differences between Lists on a background thread.

It usage DiffUtil utility class that calculates the difference between two lists and outputs a list of update operations that converts the first list into the second one.

In recycler view using a LiveData is an easy way to provide data to the adapter, with the help of list adapter it isn't required - you can simply call submitList(List) when new lists are available. You can see implementation here.

So in a case of static content you can use RecyclerView.Adapter but in case of dynamic content ListAdapter is preferred.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.