Endless RecyclerView with ProgressBar for pagination

前端 未结 9 2183
庸人自扰
庸人自扰 2020-11-27 12:51

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

9条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 13:10

    HERE IS SIMPLER AND CLEANER APPROACH.

    Implement Endless Scrolling from this Codepath Guide and then follow the following steps.

    1. Add progress bar under the RecyclerView.

        
    
        
    
        
    

    Here android:paddingBottom="50dp" and android:clipToPadding="false" are very important.

    2. Get a reference to the progress bar.

    progressBar = findViewById(R.id.progressBar);
    

    3. Define methods to show and hide progress bar.

    void showProgressView() {
        progressBar.setVisibility(View.VISIBLE);
    }
    
    void hideProgressView() {
        progressBar.setVisibility(View.INVISIBLE);
    }
    

提交回复
热议问题