2012-05-24 46 views
0

請指教我的代碼有什麼問題。錯誤:適配器內容問題

STACK_TRACE=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(2131296324, class android.widget.ListView) with Adapter(class com.platinumapps.platinumtasks.ActionsAdapter)] 
at android.widget.ListView.layoutChildren(ListView.java:1556) 
at android.widget.AbsListView$CheckForTap.run(AbsListView.java:2868) 
at android.os.Handler.handleCallback(Handler.java:587) 
at android.os.Handler.dispatchMessage(Handler.java:92) 
at android.os.Looper.loop(Looper.java:132) 
at android.app.ActivityThread.main(ActivityThread.java:4126) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:491) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) 
at dalvik.system.NativeStart.main(Native Method) 
+1

檢查你試圖改變適配器非UI線程 –

+0

發佈您的代碼也 –

+0

如果可能的話,請提供轉接器和代碼的代碼,其中適配器的數據發生變化,在那裏你通知的數據更改爲適配器。 –

回答

0

使用HandlersUI-threadsAsyncTask(postexecute)內調用notifydatasetchanged();。 你正在做它在後臺線程...

0

呼叫this內下方,把這個線程

   runOnUiThread(new Runnable(){ 
       @Override 
       public void run() { 
        // call it here 
       } 
      }