1

My app is using RecyclerView to load the data from Backend Endpoints API. After connecting the API I am getting some x amount of data. I am successfully able to load the data in StaggeredGridView in RecylerView.

Now, user scrolldown to bottom and reach at Last Position. How can I make able to another request to fetch next x amount of data and so on? (Like Gmail App does. Gmail app shows a spinner and load next span of data)

I am new in Android and How can I achieve it?

Amit Pal
  • 10,604
  • 26
  • 80
  • 160

1 Answers1

1

It is quite simple, just check the onScrolled event. You can check this answer for more details:

https://stackoverflow.com/a/26643292/4244598

You can also start loading before the user reacher the end of the list if you wish. I hope this helps you.

Community
  • 1
  • 1
Natan
  • 1,867
  • 13
  • 24
  • I looked at it but didn't able to understand where the accepted answer or Kushal answer is calling backend API after the user reached to last position of recyclerView? – Amit Pal Oct 26 '15 at 18:49
  • You can call the backend right after the loading = false; – Natan Oct 26 '15 at 20:15
  • Actually I did that but can you give me an hint how to append this data to the previous one in RecyclerView? – Amit Pal Oct 27 '15 at 04:00
  • Just append the data to the list you used to create the recyclerView's adapter and call adapter.notifyDataSetChanged() – Natan Oct 27 '15 at 16:18