Andriod ListView线程问题
来源:互联网 发布:揭东军埔淘宝村 编辑:程序博客网 时间:2024/05/17 00:47
调试程序,发现Listview的页面偶尔会出现异常,退出,分析一下,可能是Listview线程不安全的问题导致的。
程序Log:
java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(2131361792, class android.widget.ListView) with Adapter(class android.widget.SimpleAdapter)]
说的是listview 的数据更新了,但是没有通知Listview。
查找了一下解决方案:
在多线程的时候,Listview的数据源变化和绑定永远在一起,就可以避免这样的问题。
推荐的解决方案是,使用一个临时的数据源去线程接收数据。
Listview数据变更的时候,将临时数据源的数据复制给Listview的数据源,清空临时数据源。
测试了一下,问题解决了。
该问题就是需要数据源变更和更新变更永远在一起。
程序Log:
java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(2131361792, class android.widget.ListView) with Adapter(class android.widget.SimpleAdapter)]
说的是listview 的数据更新了,但是没有通知Listview。
查找了一下解决方案:
在多线程的时候,Listview的数据源变化和绑定永远在一起,就可以避免这样的问题。
推荐的解决方案是,使用一个临时的数据源去线程接收数据。
Listview数据变更的时候,将临时数据源的数据复制给Listview的数据源,清空临时数据源。
测试了一下,问题解决了。
该问题就是需要数据源变更和更新变更永远在一起。
0 0
- Andriod ListView线程问题
- Andriod ListView
- Andriod ListView implement
- Andriod学习之listview
- andriod 中的listView
- Andriod控件PopupWindow嵌套Listview
- 解决listview出现线程更新错误问题
- andriod 下的线程同步
- andriod多像素问题
- andriod时间比较问题
- andriod sdk 网络问题
- andriod配置环境问题
- andriod 蓝牙打印问题
- 哪些年遇到过的Andriod问题(8)Handler使用 mars.barhandler中的错误(测试) 线程中停止线程?
- Andriod 学习之六 Activity - ListView
- andriod listview OnScrollListener回调分析
- andriod listview实现原理以及listview的优化
- AsyncTask加载ListView和处理ImageView 更新线程问题
- java设计模式之状态模式
- 喵哈哈村的星星与月亮(二)
- 多项式相加
- Mybatis 如何传入多个参数
- 【有序链剖】Data Structure Special Training 1 T3 seqmod 题解
- Andriod ListView线程问题
- 深入浅出SQL:3 DELETE / UPDATE
- 集成学习-学习笔记
- hdu 1142 A Walk Through the Forest
- 深入PHP面向对象、模式与实践——生成对象(3)
- Opencv路径的统一修改以及不同版本路径的转换
- swift中的block
- 1135: 算菜价
- linux定时任务