The content of the adapter has changed but ListView did not receive a notification 异常解决方案
来源:互联网 发布:阿里云空间登陆 编辑:程序博客网 时间:2024/06/06 09:57
收藏己用,方便以后再遇到此问题解决~~
因为在非Ui线程中修改了ListView绑定的数据对象。这个同样会造成在非UI线程中更新主线程控件的错误。解决方法如下:
在Thread中将数据存入一个临时对象中,如下:tempAppList.add(tmpInfo);//之前是直接将 mAppsList 在这个地方用,系统就会检测到主线程中Listview绑定的数据源在改变,所以会报错
Log.i(TAG, "initAppsList send a message to show listview");
Message message = new Message();
message.what = MainActivity.SEND_INIT_LIST_MSG;
message.obj = tempAppList;
mHandler.sendMessage(message);
然后在主线程中定义的mHandler中进行数据的绑定和更新,如下:
case SEND_INIT_LIST_MSG:
Log.i(TAG, "handleMessage");
//特别注意,在非UI线程下不能够对主线程中listview绑定的list数据进行修改。只能创建一个temlist,然后在
//handle里面赋值。
mAppsList = (ArrayList<AppInfo>) msg.obj;
mAppsAdp = new AppsListAdapter(mContext, mAppsList);
lv_apps.setAdapter(mAppsAdp);
mAppsAdp.notifyDataSetChanged();
0 0
- 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异常
- 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异常
- 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异常
- 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
- Light OJ 1348 Aladdin and the Return Journey 树链剖分水题
- javascript
- 替换空格
- Android-NDK环境搭建
- 两个队列实现一个栈
- The content of the adapter has changed but ListView did not receive a notification 异常解决方案
- hdu 1162 Eddy's picture
- 多路复用时钟
- 一个简单的天气预报
- Zabbix 2.4 监控 MySQL
- poj3614 priority queue
- 最大连续子序列
- lintcode-BinarySearch-14
- $(function(){})与(function($){})(jQuery)