我正在开发一个应用程序,如果用户登录就会跳过屏幕......同时在asynctask中返回一个void ...检查应用程序的升级如果有任何它通常会打开浏览器并下载文件...并且在主线程中,如果应用程序已经存储了登录凭据,那么它将转到另一个类/屏幕。通常有一个listview ....列表是在另一个记录之后填充的....但有时我会得到应用程序崩溃的应用程序如何解决这个...和
PS。 listview的更新是从asyncTask触发的,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)
任何想法......请...
答案 0 :(得分:0)
确保已经获取了doInBackground()中的所有列表项,然后更新了onPostExecute()方法中的listview。
如果您想要更新获取项目的进度并在下载时显示项目,那么您必须更新 runOnUIThread()
内的列表视图例如:
/* Update UI */
myActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
/* Do UI update for activity A */;
}
});