Search code examples
androidandroid-layoutandroid-recyclerviewandroid-listview

Modern way of doing automatic "load more" in Android ListView/RecyclerView


I implemented https://stackoverflow.com/a/24882417 but this question is very old. My list, when the items load, gets shifted to the top, and I have to scroll all the way to the bottom again.

I think there's a better way of doing lists that automatially update when you reach the end, so I'm asking it in 2020.


Solution

  • The Android Jetpack Paging library is the current recommendation here.

    You should use a RecyclerView instead of a ListView, and then you can create an adapter that subclasses PagedListAdapter. From there, you can created PagedList instances from your data source, and submit them to your adapter via submitList. You can find more information and a detailed walkthrough in the documentation for the Paging library.