How to update RecyclerView Adapter Data?

前端 未结 13 2474
误落风尘
误落风尘 2020-11-22 03:48

Trying to figure out what is the issue with updating RecyclerView\'s Adapter.

After I get a new List of products, I tried to:

  1. Update t

13条回答
  •  孤城傲影
    2020-11-22 04:23

    The best and the coolest way to add new data to the present data is

     ArrayList newItems = new ArrayList();
     newItems = getList();
     int oldListItemscount = alcontainerDetails.size();
     alcontainerDetails.addAll(newItems);           
     recyclerview.getAdapter().notifyItemChanged(oldListItemscount+1, al_containerDetails);
    

提交回复
热议问题