相信很多人应该都用过notifyDataSetChanged();这个方法来刷新RecyclerView,显示更改后的数据。
今天我遇到了如题所说的问题。
communityBean = new Gson().fromJson(result.toString(), CommunityBean.class);
//错误示范
mlist = communityBean.getSection();
//正确做法
mlist.clear();
mlist.addAll(communityBean.getSection());
communityServiceTypeAdapter.notifyDataSetChanged();
这就是解决方法,不用=, 用addall来赋值。