The content of the adapter has changed but ListView did not receive a notification的解决方案
来源:互联网 发布:网络英语外教一对一 编辑:程序博客网 时间:2024/06/12 18:40
在Android开发过程中,使用ListView时,发现这个错误偶尔会出现。特别是做压力测试的时候,不停的点击刷新,更容易出现这个错误。
在网上找了一下关于这个问题的解决办法,说的是直接备份一份数据源,我根据他们说的,办法是可行的,上代码。
public void setDataList(ArrayList<Map<String, Object>> dataList) { if (dataList != null) { mDatas = (List<Map<String, Object>>) dataList.clone(); notifyDataSetChanged(); }}public void clearDataList() { if (mDatas != null) { mDatas.clear(); }}
在刷新的时候,调用setDataList()方法,这只是一种迂回的方法,后来发现本质的原因,还是因为在刷新适配器的时候,调用接口之前,清空了数据源的内容,然后再填充适配器,导致的数据源与适配器不匹配。上代码。if (mNotificationAdapter == null) { mNotificationAdapter = new AdpFragNotificationList(mActivity); mNotiSwipeView.setAdapter(mNotificationAdapter);}mNotificationAdapter.setDataList(mNotiList);
mPromotionSwipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mPromotionList.clear(); getDataList(false, 0); }});只需要将数据源中的清除放到更新适配器前清除即可。
1 0
- The content of the adapter has changed but ListView did not receive a notification的解决方案
- The content of the adapter has changed but ListView did not receive a notification 异常解决方案
- The content of the adapter has changed but ListView did not receive a notification 错误的解决方案
- The content of the adapter has changed but ListView did not receive a notification 错误的解决方案
- The content of the adapter has changed but ListView did not receive a notification 错误的解决方案
- android报The content of the adapter has changed but ListView did not receive a notification的解决方案
- listview提示The content of the adapter has changed but ListView did not receive a notification
- ListView异常:The content of the adapter has changed but ListView did not receive a notification
- ListView The content of the adapter has changed but ListView did not receive a notification.
- The content of the adapter has changed but ListView did not receive a notification.
- The content of the adapter has changed but ListView did not receive a notification
- 解决bug:The content of the adapter has changed but ListView did not receive a notification
- The content of the adapter has changed but ListView did not receive a notification
- The content of the adapter has changed but ListView did not receive a notification.
- The content of the adapter has changed but ListView did not receive a notification
- .解决bug:The content of the adapter has changed but ListView did not receive a notification .
- The content of the adapter has changed but ListView did not receive a notification终极解决方法
- 处理The content of the adapter has changed but ListView did not receive a notification异常
- HDU-3533
- init进程【1】——init启动过程
- 判断一个数的奇偶性
- C语言程序设计谭浩强版 五
- The beginning
- The content of the adapter has changed but ListView did not receive a notification的解决方案
- 初步理解android的MediaScanner(1)
- linux--tomcat安装
- 顺序表应用2:多余元素删除之建表算法
- 图标素材网站
- 使用ArrayList对大小写字母的随机打印
- Android开发之蓝牙通信(二)
- Hibernate二级缓存的全局配置
- Hibernate1