Forum Xamarin Xamarin.Android

Fixing ListView adapter state exception

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(2131230761, class android.widget.ListView) with Adapter(class ....)

I'm having problems with the exception shown above. I have a Fragment that displays a ListView that is populated by a local class the derives from BaseAdapter. My adapter is populated with data from a webservice that I call on a background thread. When I have the data I notify the ListView on the UIThread with.

Activity.RunOnUiThread (() => {

When I close this view and return to it I sometimes get this exception. I think the ListView is trying to layout its self out, while my thread is trying to get the necessary data. Can I synchronize these 2 things? or does anyone have any other ideas?



  • CheesebaronCheesebaron DKInsider, University mod

    Post some code or a reproducible sample and it will be so much easier to tell you what to do.

Sign In or Register to comment.