0

我正在开发一个应用程序,如果用户登录,它会跳过一个屏幕......同时在一个返回无效的异步任务中......检查应用程序的升级,如果有是什么它通常会打开浏览器并下载文件......并且在主线程中,如果应用程序已经存储了登录凭据,那么它会转到另一个类/屏幕。通常有一个列表视图....该列表一个接一个地填充另一个记录....但在这之间有时我会遇到应用程序崩溃,我该如何解决这个问题...和

PS。对列表视图的更新是从通常调用主线程中的函数来更新视图的 asyncTask 触发的,...

    11-01 12:30:27.038: WARN/dalvikvm(10067): threadid=1: thread exiting with uncaught exception (group=0x400207d8)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067): FATAL EXCEPTION: main
11-01 12:30:27.038: ERROR/AndroidRuntime(10067): 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 biz.graphight.graphight.CallSheetTab$CustomAdapter)]
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.widget.ListView.layoutChildren(ListView.java:1567)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.widget.AbsListView.onLayout(AbsListView.java:1263)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.view.View.layout(View.java:7035)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.widget.RelativeLayout.onLayout(RelativeLayout.java:909)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.view.View.layout(View.java:7035)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.view.View.layout(View.java:7035)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.view.View.layout(View.java:7035)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.view.View.layout(View.java:7035)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.os.Looper.loop(Looper.java:123)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at android.app.ActivityThread.main(ActivityThread.java:4628)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at java.lang.reflect.Method.invokeNative(Native Method)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at java.lang.reflect.Method.invoke(Method.java:521)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:879)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:637)
11-01 12:30:27.038: ERROR/AndroidRuntime(10067):     at dalvik.system.NativeStart.main(Native Method)

任何想法...请...

4

1 回答 1

0

确保您已获取 doInBackground() 中的所有列表项,然后更新 onPostExecute() 方法中的列表视图。

如果您想更新获取项目的进度并在下载项目时显示项目,那么您必须更新runOnUIThread()中的列表视图

例如:

/* Update UI */
myActivity.this.runOnUiThread(new Runnable() {
   @Override
   public void run() {
        /* Do UI update for activity A */;
   }
 });

相关关于runOnUiThread的问题

于 2011-11-01T07:23:30.270 回答