10-10 20:37:19.576: ERROR/AndroidRuntime(7619): Uncaught handler: thread main exiting due to uncaught exception
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): 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(2131296396, class android.widget.ListView) with Adapter(class android.widget.HeaderViewListAdapter)]
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.ListView.layoutChildren(ListView.java:1432)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.AbsListView.onLayout(AbsListView.java:1119)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.View.layout(View.java:6836)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:900)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.View.layout(View.java:6836)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:900)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.View.layout(View.java:6836)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:900)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.View.layout(View.java:6836)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.View.layout(View.java:6836)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.View.layout(View.java:6836)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.View.layout(View.java:6836)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.View.layout(View.java:6836)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.View.layout(View.java:6836)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:998)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.LinearLayout.onLayout(LinearLayout.java:918)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.View.layout(View.java:6836)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.View.layout(View.java:6836)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.View.layout(View.java:6836)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.View.layout(View.java:6836)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.ViewRoot.performTraversals(ViewRoot.java:1003)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.view.ViewRoot.handleMessage(ViewRoot.java:1640)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.os.Handler.dispatchMessage(Handler.java:99)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.os.Looper.loop(Looper.java:205)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at android.app.ActivityThread.main(ActivityThread.java:4409)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at java.lang.reflect.Method.invokeNative(Native Method)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at java.lang.reflect.Method.invoke(Method.java:521)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-10 20:37:19.586: ERROR/AndroidRuntime(7619): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
问问题
288 次
1 回答
2
您收到此异常是因为您正在从后台线程更改适配器的内容。请更改您的实现,以便您仅从 UI 线程更新您的适配器。
异常本身提到了这一点:
java.lang.IllegalStateException:适配器的内容已更改,但 ListView 没有收到通知。确保适配器的内容不是从后台线程修改的,而只是从 UI 线程修改的。
这是一个关于正确使用 ListViews 和适配器的好教程: http ://www.vogella.com/articles/AndroidListView/article.html
于 2012-10-10T15:20:20.133 回答