嗨,每次我安装应用程序时,打开它而不是用后退按钮关闭它,然后再次重新打开它,我得到同样的错误:
05-05 10:49:35.453: ERROR/AndroidRuntime(5118): 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(2131361820, class android.widget.ListView) with Adapter(class com.TVSpored.ChannelItemAdapter)]
我读过我必须制作 onRestart 函数(LINK)......但我不知道如何处理它......
onCreate 函数执行以下操作:
- 设置布局
- 设置所有必要的对象(ProgressDialog、ArrayList、ChannelItemAdapter、channelDBAdapter)
- 在 asynctask 中加载数据:
new LoadChannels().execute(channelItem);
正如我之前所说,它在 onStart 和浏览应用程序时完美运行......但是当离开应用程序并重新启动它时,它总是崩溃......
谢谢你的帮助!
添加代码:
protected ArrayList<ToDoItem> doInBackground(ArrayList<ToDoItem>... passing)
{
cItems = passing[0]; //get passed arraylist
toDoListCursor = channelDBAdapter. getAllToDoItemsCursor();
startManagingCursor(toDoListCursor);
channelItem.clear();
if (toDoListCursor.moveToFirst())
do
{
String task = toDoListCursor.getString(toDoListCursor.getColumnIndex(ToDoDBAdapter.KEY_NAME));
String created = toDoListCursor.getString(toDoListCursor.getColumnIndex(ToDoDBAdapter.KEY_EPG_NAME));
int fav = toDoListCursor.getInt(toDoListCursor.getColumnIndex(ToDoDBAdapter.KEY_FAV));
int id = toDoListCursor.getInt(toDoListCursor.getColumnIndex(ToDoDBAdapter.KEY_EPG_ID));
int ch_type = toDoListCursor.getInt(toDoListCursor.getColumnIndex(ToDoDBAdapter.KEY_CH_CHTYPE_ID));
int country = toDoListCursor.getInt(toDoListCursor.getColumnIndex(ToDoDBAdapter.KEY_CH_COU_ID));
ToDoItem newItem = new ToDoItem(task, created, fav, id, ch_type, country);
channelItem.add(0, newItem);
}
while(toDoListCursor.moveToNext());
return cItems; //return result
}