0

我正在處理一個應用程序,如果用戶登錄時只會跳過一個屏幕....同時在一個返回void的asynctask中...檢查應用程序的升級和如果有任何它通常會打開一個瀏覽器並下載一個文件...並在主線程中,如果應用程序已經存儲了登錄憑證,那麼它會進入另一個類/屏幕。它通常有一個列表視圖....列表是一個接一個地填充另一個記錄....但在兩者之間有時我得到應用程序崩潰的應用程序如何解決這個問題...和listView有一個IllegalStateException - 在打開屏幕之前打開一個瀏覽器。

PS。更新到ListView正從通常要求在主線程的功能更新視圖,一個觸發的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

確保您已經獲取了doInBackground()中的所有列表項,然後更新了onPostExecute()方法內的listview。

如果您想更新獲取項目和顯示項目作爲與進步,當它被下載,那麼你必須更新runOnUIThread()

內部列表視圖例如:

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

相關Question about runOnUiThread

+0

非常感謝。那會做。 – medampudi

相關問題