我有两个活动。一个活动有listview,第二个活动有gridview ..我从listview活动点击下一个活动将安全打开但是当我按下来自模拟器listacitivity的按钮会显示但是当我再次点击listactivity时它给我forceclose选项和我的应用程序崩溃... Logcat错误就在那里..
01-30 05:32:24.748: E/AndroidRuntime(998): FATAL EXCEPTION: main
01-30 05:32:24.748: E/AndroidRuntime(998): 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(16908298, class android.widget.ListView) with Adapter(class android.widget.ArrayAdapter)]
01-30 05:32:24.748: E/AndroidRuntime(998): at android.widget.ListView.layoutChildren(ListView.java:1538)
01-30 05:32:24.748: E/AndroidRuntime(998): at android.widget.AbsListView.onTouchEvent(AbsListView.java:3513)
01-30 05:32:24.748: E/AndroidRuntime(998): at android.view.View.dispatchTouchEvent(View.java:7127)
01-30 05:32:24.748: E/AndroidRuntime(998): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2170)
01-30 05:32:24.748: E/AndroidRuntime(998): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1905)
01-30 05:32:24.748: E/AndroidRuntime(998): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
01-30 05:32:24.748: E/AndroidRuntime(998): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
01-30 05:32:24.748: E/AndroidRuntime(998): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
01-30 05:32:24.748: E/AndroidRuntime(998): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
01-30 05:32:24.748: E/AndroidRuntime(998): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
01-30 05:32:24.748: E/AndroidRuntime(998): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
01-30 05:32:24.748: E/AndroidRuntime(998): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1925)
01-30 05:32:24.748: E/AndroidRuntime(998): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1379)
01-30 05:32:24.748: E/AndroidRuntime(998): at android.app.Activity.dispatchTouchEvent(Activity.java:2396)
01-30 05:32:24.748: E/AndroidRuntime(998): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1873)
答案 0 :(得分:0)
没有代码,很难说出什么可能是错的。但我能想到的最可行的解决方案是,
我认为您正在第二个Activity中执行一些计算,这些计算正在修改List活动中显示的内容。
当您打开second activity
时,只需finish()
first Activity
和第二个活动中的后退按钮(覆盖onBackPressed()
)即可创建新的Intent
打开第一个活动。
如果您需要有关如何覆盖onBackPressed()
功能的帮助,请与我们联系。