【遇见Android bug】The content of the adapter has changed but ListView did not receive a notification

来源:互联网 发布:linux设置ntp服务器 编辑:程序博客网 时间:2024/06/10 04:44

bug日志如下:

The content of the adapter has changed but ListView did not receive a notification

遇到这个问题的情境是在AsyncTask的doInBackground中对数据集执行了clear()操作。而在onPostExecuter中执行了mAdapter.notifyDataSetChanged()动作。

为了避免出现此问题,撸代码时应该尽量避免在后台线程中操作数据集,如上的clear()操作等。建议在AsyncTask执行前处理数据集的清空和重置操作,或者在onPostExecuter()方法中执行数据集的清空和重置操作。


0 0