我有共同的問題:Android的猴子導致適配器通知例外android.widget.HeaderViewListAdapter
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)]
但適配器是不是我的代碼,但在android.widget.HeaderViewListAdapter
這是使用傑利貝恩。
我通過HeaderViewListAdapter
,ListAdapter
和ListView
的源代碼讀取。當ListView
中的物品計數不等於ListAdapter
提供的計數時,將引發IllegalStateException
。在這種情況下,ListAdapter
是HeaderViewListAdapter
。 HeaderViewListAdapter
s計數是客戶端代碼傳遞的原始ListAdapter
的計數,再加上頁眉和頁腳的大小。
我追溯了我的代碼。所有對ListView
的訪問都在UI線程上,並且後面總是後跟notifyDataSetChanged()
。我正在使用一個頁腳。
這在正常使用情況下不會發生。是因爲猴子嗎?但是猴子怎麼能從其他線程修改我的變量呢?
- 更新後更猴子測試
我通過刪除調用addFooterView()
刪除頁腳。猴子不再觸發異常。我應該在某個時候刪除對addFooterView()
的呼叫嗎?
請告訴我你找到了解決方案! – StErMi
我有同樣的問題,但它也發生在猴子用法之外。我無法重現這個問題,並且猴子在20K次迭代後沒有錯誤地完成了很多次。 – StErMi
對不起,我沒有找到解決方案。但是,我沒有看到猴子使用以外的這個問題。 – mparaz