How to load more data in recycler view from server?

前端 未结 3 1562
一个人的身影
一个人的身影 2021-01-17 06:30

I have a recycler view in which I load some data from the server when user scroll to bottom I want to show a progress bar and send another request to the server for more dat

3条回答
  •  不思量自难忘°
    2021-01-17 07:07

    Fetching the data from server is a Async Task. So you need to enclose the updation code in a runOnUiThread runnable. to change UI.

    runOnUiThread(new Runnable() {
       @Override
       public void run() {
          mUsers.remove(mUsers.size() - 1);
          mUserAdapter.notifyItemRemoved(mUsers.size());
          //sending request to server for more data
          moreDealsRequest();
          mUserAdapter.notifyDataSetChanged();
          mUserAdapter.setLoaded();
    }});
    

提交回复
热议问题