mpa*_*raz 5 android android-monkey
我有一个共同的问题:
java.lang.IllegalStateException: The content of the adapter has changed but List
View did not receive a notification. Make sure the content of your adapter is no
t modified from a background thread, but only from the UI thread. [in ListView(2
131427573, class android.widget.ListView) with Adapter(class android.widget.Head
erViewListAdapter)]
Run Code Online (Sandbox Code Playgroud)
但是适配器不是我的代码,而是在android.widget.HeaderViewListAdapter
使用Jellybean.
我通过对源代码的阅读HeaderViewListAdapter,ListAdapter和ListView.该IllegalStateException当项目在计数时,抛出ListView不等于所提供的计数ListAdapter.在这种情况下,ListAdapter是HeaderViewListAdapter.该HeaderViewListAdaptercount:伯爵是原来的数ListAdapter由客户端代码中传递,再加上页眉和页脚的大小.
我追查了我的代码.所有访问ListView都在UI线程上,并始终跟随notifyDataSetChanged()适配器.我正在使用一个页脚.
在正常使用中不会发生这种情况.是猴子吗?但是Monkey如何从其他线程修改我的变量?
我通过删除呼叫删除了页脚addFooterView().Monkey不再触发异常.我应该addFooterView()在某个时候取消电话吗?
你可以尝试在ListView中添加这样的东西:
@Override
protected void layoutChildren() {
try {
super.layoutChildren();
} catch (IllegalStateException e) {
ZLog.e(LOG, "This is not realy dangerous problem");
}
}
Run Code Online (Sandbox Code Playgroud)
如果添加headerview或footerview ListView,并且当你通知notifyDataSetChanged()时,它会将mItemCount更改为真实适配器的项目数,但右侧将返回添加了headercount和footercount的虚假itemcount.
| 归档时间: |
|
| 查看次数: |
2197 次 |
| 最近记录: |