Привет каждый раз, когда я устанавливаю приложение, открываю его, затем закрываю его кнопкой «Назад», а затем снова открываю его, я получаю ту же ошибку:
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)
- Загружает данные в асинхронном режиме:
new LoadChannels().execute(channelItem);
Как я уже говорил, он отлично работает при запуске и при просмотре приложения ... но при выходе из приложения и его перезапуске всегда происходит сбой ...
Спасибо за вашу помощь!
Добавлен код:
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
}