I am using a RecyclerView
and fetching objects from an API in batches of ten. For pagination, I use EndlessRecyclerOnScrollListener
.
It's all working properly. Now all that's left is to add a progress spinner at the bottom of the list while the next batch of objects is fetched by the API. Here is a screenshot of the Google Play Store app, showing a ProgressBar
in what is surely a RecyclerView
:
The problem is, neither the RecyclerView
nor the EndlessRecyclerOnScrollListener
have built-in support for showing a ProgressBar
at the bottom while the next batch of objects is being fetched.
I have already seen the following answers:
1. Put an indeterminate ProgressBar
as footer in a RecyclerView
grid.
2. Adding items to Endless Scroll RecyclerView
with ProgressBar
at bottom.
I am not satisfied with those answers (both by the same person). This involves shoehorning a null
object into the data-set midway while the user is scrolling and then taking it out after the next batch is delivered. It looks like a hack that sidesteps the main problem which may or may not work properly. And it causes a bit of jarring and distortion in the list
Using SwipeRefreshLayout
is not a solution here. SwipeRefreshLayout
involves pulling from the top to fetch the newest items, and it does not show a progress view anyway.
Can someone please provide a good solution for this? I am interested in knowing how Google has implemented this for their own apps (the Gmail app has it too). Are there any articles where this is shown in detail? All answers & comments will be appreciated. Thank you.
Some other references:
1. Pagination with RecyclerView
. (Superb overview ...)
2. RecyclerView
header and footer. (More of the same ...)
3. Endless RecyclerView
with ProgressBar
at bottom.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…