Set notifyDataSetChanged() on Recyclerview adapter

前端 未结 5 994
说谎
说谎 2020-12-11 02:25

I\'m implementing an endless data loading for a RecyclerView. When software detects that last item is going to be shown, it downloads new items and call to the loadMor

5条回答
  •  再見小時候
    2020-12-11 02:36

    you are setting the new list to the RecyclerView Adapter , set the list in the Adapter:

    make a method setItems(list) in adapter and call it before notifyDataSetChanged() and in adapter do

    this.persons = new ArrayList<>(persons);
    

    in setItems

    add this method in adapter:

    public void setItems(List persons) {
        this.persons = persons;
    }
    

    and call it before notifyDataSetChanged() like this:

    adapter.setItems(list);
    adapter.notifyDataSetChanged();
    

提交回复
热议问题