added in version 27.1.0
belongs to Maven artifact


public abstract class ListAdapter
extends Adapter<VH extends RecyclerView.ViewHolder>

   ↳<VH extends>
     ↳<T, VH extends>

RecyclerView.Adapter base class for presenting List data in a RecyclerView, including computing diffs between Lists on a background thread.

This class is a convenience wrapper around AsyncListDiffer that implements Adapter common default behavior for item access and counting.

While using a LiveData<List> is an easy way to provide data to the adapter, it isn't required - you can use submitList(List) when new lists are available.

A complete usage pattern with Room would look like this:

 interface UserDao {
     @Query("SELECT * FROM user ORDER BY lastName ASC")
     public abstract LiveData<List<User>> usersByLastName();

 class MyViewModel extends ViewModel {
     public final LiveData<List<User>> usersList;
     public MyViewModel(UserDao userDao) {
         usersList = userDao.usersByLastName();

 class MyActivity extends AppCompatActivity {
     public void onCreate(Bundle savedState) {
         MyViewModel viewModel = ViewModelProviders.of(this).get(MyViewModel.class);
         RecyclerView recyclerView = findViewById(;
         UserAdapter<User> adapter = new UserAdapter();
         viewModel.usersList.observe(this, list -> adapter.submitList(list));

 class UserAdapter extends ListAdapter<User, UserViewHolder> {
     public UserAdapter() {
     public void onBindViewHolder(UserViewHolder holder, int position) {
     public static final DiffUtil.ItemCallback<User> DIFF_CALLBACK =
             new DiffUtil.ItemCallback<User>() {
         public boolean areItemsTheSame(
                 @NonNull User oldUser, @NonNull User newUser) {
             // User properties may have changed if reloaded from the DB, but ID is fixed
             return oldUser.getId() == newUser.getId();
         public boolean areContentsTheSame(
                 @NonNull User oldUser, @NonNull User newUser) {
             // NOTE: if you use equals, your object must properly override Object#equals()
             // Incorrectly returning false here will result in too many animations.
             return oldUser.equals(newUser);
Advanced users that wish for more control over adapter behavior, or to provide a specific base class should refer to AsyncListDiffer, which provides custom mapping from diff events to adapter positions.


Protected constructors

ListAdapter(ItemCallback<T> diffCallback)
ListAdapter(AsyncDifferConfig<T> config)

Public methods

int getItemCount()

Returns the total number of items in the data set held by the adapter.

void submitList(List<T> list)

Submits a new list to be diffed, and displayed.

Protected methods

T getItem(int position)

Inherited methods

From class