我有一個IntentService,它在WindowManager的幫助下創建一個Overlay。在WindowManager中,我添加一個包含ListView的View。現在我想一個新的項目在onHandleIntent方法添加到ListView,但如果我叫從IntentService更新ListView
data.add("String");
adapter.notifyDataSetChanged();
系統將引發錯誤
Only the original thread that created a view hierarchy can touch its views.
我能做些什麼來防止這種情況?
看一看[內容提供者(http://developer.android.com/guide/topics/providers/content-providers.html)。他們會幫助你。 – 2013-03-19 17:39:19
在onStart中創建一個處理程序,然後在這個處理程序上發佈消息來更新視圖,如果我正確理解你在做什麼。 – njzk2 2013-03-19 17:46:46