I am fetching 1000 items from server at a time and displaying it in Recycler view. Is there any way I can fetch 50 items a time from server and then fetch next 50 from server and then on-wards from server as well? If not possible, then how can I display only 50 item in recycler view at first and then respective on load more button click?
Asked
Active
Viewed 41 times
-1
-
Possible duplicate of [How to implement endless list with RecyclerView?](https://stackoverflow.com/questions/26543131/how-to-implement-endless-list-with-recyclerview) – Sniffer Oct 16 '18 at 09:54
-
Yes, it is possible. it's called "Pagination of data", you can use `OnScrollListener` for `RecyclerView` and load more data from there. – Jeel Vankhede Oct 16 '18 at 09:55
-
1use google's [paging](https://developer.android.com/topic/libraries/architecture/paging.html) support library - do not use any custom `OnScrollListener`s – pskink Oct 16 '18 at 09:57
2 Answers
0
Api should build in a way that it can process according LIMIT and OFFSET
server side query will be like.... SELECT contact_id, last_name, first_name FROM contacts ORDER BY contact_id DESC LIMIT 5 OFFSET 2;

kuber singh
- 289
- 1
- 5
-
than you can hit api onScrollListener at end index, getting 1000 data may slow down the app – kuber singh Oct 16 '18 at 09:57
-
1
0
you should select the first 50 items and after selecting generate a token for next item to next 50 item

Mr Robot
- 61
- 4