Search code examples
scrolladapterandroid-recyclerviewinfinite

Android- RecyclerView Adapter - How to implement endless scrolling without deleting previous items


I'm developing an app to get tweets and display them on screen. I've user RecyclerView and it works fine.

The thing is that when I get to the last item, I'm swapping the adapter in order to get new items, but the previous items get deleted and I can't scroll back to view them.

recyclerView.swapAdapter(adapter,true);

How can I implement endless scrolling without losing my previous values ?

Thanks!


Solution

  • The answer is here:

    http://antonioleiva.com/recyclerview/

    All I've had to do is add items to the list of items that's already in the adapter and then use "notifyItemInserted(position)".

    Same idea for removal.