Skip to content Skip to sidebar Skip to footer

Load More Than 10 Items In Recyclerview With Gridlayoutmanager Of 3 Span Count On First Time

I using GridLayoutManager with 3 span count in recyclerView on my app, the problem is when I run the app first time it's showing only first 10 items due to the the restriction / pa

Solution 1:

The problem is that your items count is not enough to fill the entire page. There are two ways to overcome this issue.

  1. You can call your getData method one more time after loading the first batch to get more data which is not a clean solution since you might need more items on larger screens like tablets.

  2. Put your load more procedure in onBindViewHolder method of your recycler view adapter instead of its on scroll listener. You can do the load more if position == getItemCount()-1 for instance which requests server for more items if your last item gets in view (or needs binding). Remember that you have to hold a boolean in order to prevent repetitive calls on your getData.

Post a Comment for "Load More Than 10 Items In Recyclerview With Gridlayoutmanager Of 3 Span Count On First Time"