How to update RecyclerView Adapter Data?

前端 未结 13 2309
误落风尘
误落风尘 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:33

    This is what worked for me:

    recyclerView.setAdapter(new RecyclerViewAdapter(newList));
    recyclerView.invalidate();
    

    After creating a new adapter that contains the updated list (in my case it was a database converted into an ArrayList) and setting that as adapter, I tried recyclerView.invalidate() and it worked.

提交回复
热议问题