0

こんにちは、アプリをインストールするたびに、戻るボタンで閉じるよりも開いてから、もう一度開くと同じエラーが発生します。

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 関数は次のことを行います。

  1. セットレイアウト
  2. 必要なすべてのオブジェクトを設定します (ProgressDialog、ArrayList、ChannelItemAdapter、channelDBAdapter)
  3. asynctask にデータをロードします。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
}
4

1 に答える 1

0

あなたが提供したスタック トレースから、UI スレッドの外で ListView アダプターの内容を変更しているようです。ASyncTask を見て、UI スレッド (たとえば doInBackground ではなく) で実行されるメソッドに対してのみアダプターで変更を実行することを確認する必要があると思います。

ASyncTaskを参照してください

于 2011-05-05T09:10:41.380 に答える