1

I am using three tabs.when i click the tab, an activity starts that displays multiple listview with header.For that i use listadapter and my code seems adapter.addsection("Header String",new ArrayAdapter(this,R.layout.row,cursor,from,to); then i set list using list.setadapter(adapter).It all works fine when i click the tab.My problem occurs, after i scroll my listview which is in another activity and press emulator back button and clicking tab.Now when i am clicking tab,my application crashes and logcat shows the following error.

 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. [in ListView(-1, class android.widget.ListView) with Adapter(class com.t.s.SeperatedListAdapter)]

Whats the solution for this? I used adapter.notifydatasetchanged() to solve this.Eventhough i couldn't.

Mercy
  • 1,862
  • 9
  • 39
  • 75
  • check the following answers from the links [stackoverflow][1] [stackoverflow][2] [stackoverflow][3] [1]: http://stackoverflow.com/questions/3132021/android-listview-illegalstateexception-the-content-of-the-adapter-has-changed [2]: http://stackoverflow.com/questions/6478649/listview-illegalstateexception-the-content-of-the-adapter-has-changed-but-list [3]: http://stackoverflow.com/questions/4290806/how-to-solve-this-issuethe-content-of-the-adapter-has-changed-but-listview-did – user1203673 Feb 23 '12 at 09:45

1 Answers1

0

the reason is: your data is changed, when back to previous activity, the listview will auto refresh, this time system found the data changed but no notifyDataChanged invoke, so throw the error.

so if another activity change the data, you can try: in your previous activity in method: onResume, try use notifyDataChanged to notify.

idiottiger
  • 5,147
  • 2
  • 25
  • 21