I am having the common problem:
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)]
But the adapter is not my code, but in android.widget.HeaderViewListAdapter
This is using Jellybean.
I read through the source code of HeaderViewListAdapter
, ListAdapter
and ListView
. The IllegalStateException
is thrown when the item count inListView
is not equal to the count provided by the ListAdapter
. In this case, the ListAdapter
is the HeaderViewListAdapter
. The HeaderViewListAdapter
s count is the count of the original ListAdapter
passed by the client code, plus the size of the header and footer.
I traced through my code. All access to the ListView
is on the UI thread, and is always followed by notifyDataSetChanged()
to the adapter. I am using one footer.
This doesn't occur in normal usage. Is it due to Monkey? But how can Monkey modify my variables from other threads?
- Update after more Monkey Testing
I removed the footer by removing the call to addFooterView()
. Monkey no longer triggers the exception. Should I remove the call to addFooterView()
at some point?