Make RecyclerView support load more feature.

RecyclerView is a library from Android official. With witch, we can create rich and colorful user interface more easily.

SwipeRefreshLayout is another library from Android official and it support pull-to-refresh feature with any layout in it.

We use both of them to create list with refresh and load more abilities, but the load more feature is not supported by default, so I created LoadMoreRecyclerViewAdapter class to support it.


It’s has only one .java file so you can just copy-paste that file to your project. I did want to use gist but was stuck by my network.

It is an Adapter for RecyclerView, so you use it just like before. There are some NOTICES.

  1. Instantiate this class with a LayoutManager object.
  2. Call RecyclerView.addOnScrollListener(LoadMoreRecyclerViewAdapter.getOnRecyclerScrollChangeListener()); to listen the scroll event of RecyclerView.
  3. Call super.onCreateViewHolder(parent, viewType); in onCreateViewHolder() method to create footer view holder.
  4. Call super.onBindViewHolder(holder, position); in onBindViewHolder() method.
  5. Override getActualItemCount() method to return actual data item count.
  6. Override onCreateLoadMoreFooter() method to create footer view that implements ILoadMoreFooter.
  7. Call setLoadMoreComplete() method to complete loading.
  8. Call setHasMore() method to configure whether have more data.