Skip to content

Most visited

Recently visited



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

   ↳<VH extends>
     ↳ android.arch.paging.PagedListAdapter<T, VH extends>

RecyclerView.Adapter base class for presenting paged data from PagedLists in a RecyclerView.

This class is a convenience wrapper around PagedListAdapterHelper that implements common default behavior for item counting, and listening to PagedList update callbacks.

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

PagedListAdapter listens to PagedList loading callbacks as pages are loaded, and uses DiffUtil on a background thread to compute fine grained updates as new PagedLists are received.

Handles both the internal paging of the list as more data is loaded, and updates in the form of new PagedLists.

A complete usage pattern with Room would look like this:

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

 class MyViewModel extends ViewModel {
     public final LiveData<PagedList<User>> usersList;
     public MyViewModel(UserDao userDao) {
         usersList = userDao.usersByLastName().create(
                 /* initial load position */ 0,
                 new PagedList.Config.Builder()

 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, pagedList -> adapter.setList(pagedList));

 class UserAdapter extends PagedListAdapter<User, UserViewHolder> {
     public UserAdapter() {
     public void onBindViewHolder(UserViewHolder holder, int position) {
         User user = getItem(position);
         if (user != null) {
         } else {
             // Null defines a placeholder item - PagedListAdapter will automatically invalidate
             // this row when the actual object is loaded from the database
     public static final DiffCallback<User> DIFF_CALLBACK = new DiffCallback<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 PagedListAdapterHelper, which provides the mapping from paging events to adapter-friendly callbacks.


Protected constructors

PagedListAdapter(DiffCallback<T> diffCallback)

Creates a PagedListAdapter with default threading and ListUpdateCallback.

PagedListAdapter(ListAdapterConfig<T> config)

Public methods

PagedList<T> getCurrentList()

Returns the list currently being displayed by the Adapter.

int getItemCount()
void setList(PagedList<T> pagedList)

Set the new list to be displayed.

Protected methods

T getItem(int position)

Inherited methods

From class
From class java.lang.Object

Protected constructors


PagedListAdapter (DiffCallback<T> diffCallback)

Creates a PagedListAdapter with default threading and ListUpdateCallback. Convenience for PagedListAdapter(ListAdapterConfig), which uses default threading behavior.

diffCallback DiffCallback: The DiffCallback instance to compare items in the list.


PagedListAdapter (ListAdapterConfig<T> config)

config ListAdapterConfig

Public methods


PagedList<T> getCurrentList ()

Returns the list currently being displayed by the Adapter.

This is not necessarily the most recent list passed to setList(PagedList), because a diff is computed asynchronously between the new list and the current list before updating the currentList value.

PagedList<T> The list currently being displayed.


int getItemCount ()



void setList (PagedList<T> pagedList)

Set the new list to be displayed.

If a list is already being displayed, a diff will be computed on a background thread, which will dispatch Adapter.notifyItem events on the main thread.

pagedList PagedList: The new list to be displayed.

Protected methods


T getItem (int position)

position int


This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)