android The content of the adapter has changed but ListView did not receive a notification 错误的解决方案
2013-10-25 15:40
471 查看
使用了AsyncTask在后台刷新适配器,并且通知ui线程更新ListView,运行时发现时不时的出现 如题 的错误,
导致程序崩溃,解决方法如下:
1.建立一个缓冲数据集,这个数据集就是填充适配器的数据集,如ArrayList<String>
2.在AsyncTask的后台方法(doInBackground)中将数据添加至缓冲数据集中,然后调用onProgressUpdate通知更新
3.在onProgressUpdate方法中,将缓冲数据集的数据添加至原数据集中,然后将缓冲数据集中的数据清空
注意:访问缓冲数据集的时候,需要加上同步锁 synchronized
导致程序崩溃,解决方法如下:
1.建立一个缓冲数据集,这个数据集就是填充适配器的数据集,如ArrayList<String>
2.在AsyncTask的后台方法(doInBackground)中将数据添加至缓冲数据集中,然后调用onProgressUpdate通知更新
3.在onProgressUpdate方法中,将缓冲数据集的数据添加至原数据集中,然后将缓冲数据集中的数据清空
注意:访问缓冲数据集的时候,需要加上同步锁 synchronized
相关文章推荐
- 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的解决方案
- Android开发-- The content of the adapter has changed but ListView did not receive a notification - With AsyncTask
- The content of the adapter has changed but ListView did not receive a notification 异常解决方案
- 【遇见Android 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的解决方案
- Android - Bug: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
- 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 anotification
- 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 更新ListView报 The content of the adapter has changed but ListView did not recive 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