要刷新RecyclerView中的數(shù)據(jù),可以通過以下方法:
示例代碼:
// 更新數(shù)據(jù)集
List<Data> newData = new ArrayList<>();
// 添加數(shù)據(jù)到newData
// 更新RecyclerView的數(shù)據(jù)集
adapter.setData(newData);
// 調(diào)用Adapter的notifyDataSetChanged()方法刷新數(shù)據(jù)
adapter.notifyDataSetChanged();
上述代碼中的adapter是RecyclerView的Adapter,setData()方法用于設(shè)置新的數(shù)據(jù)集,notifyDataSetChanged()方法用于通知適配器數(shù)據(jù)已經(jīng)改變,需要刷新RecyclerView。