我在使用PullToRefreshListView的时候,发现在我下拉刷新的时候,如果我快速的点击item,就会报错:
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. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(16908298, class com.handmark.pulltorefresh.library.PullToRefreshListView$InternalListViewSDK9) with Adapter(class android.widget.HeaderViewListAdapter)]
但是当我在adpater中,给item添加了点击事件后,就不会报错了,这是为什么?
我的代码逻辑是这样的:首先在activity中声明了list用来存储数据,然后用pulltorefreshlistview.setAdapter,下拉刷新的时候,模拟网络加载,启动了一个Asyctask来给list添加数据,添加完成后再用notifydatasetchanged,如果在正在刷新的话,我会直接pulltorefreshlistview.onfreshcompete。在adapter中,假如我没有给整个item布局添加点击事件的话,那么在正在刷新的时候,我快速的点击item就会报上面的错误。如果我在adapter中给整个item添加了点击事件的话,就不会报错,这是为什么?
android PullToRefreshListView报错
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
3条回答 默认 最新
qq_28245309 2016-12-02 08:18关注notifyDataSetChanged()这句应该在UI线程调用试试
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报