図 1 では、リスト内の 1 つのアイテムを選択した後、履歴と言って、新しいアクティビティが開始されます。画像2枚目をご覧ください。画像 2 では、クリックしてリストに戻ると、画像 3 のようにリスト内の項目が繰り返されます。
なぜこれが起こるのですか?
以下は私のコードの一部です:
public class CategoryListActivity extends ListActivity implements LoaderCallbacks<List<Category>> {
String url = "http://vlm1.uta.edu/~zhangzhong/questions.json";
private ArrayAdapter<Category> mListAdapter;
//private ListView listview;
//private ArrayList<Category> categories = new ArrayList<Category>();
private static final int LOADER_ID_CHECKS = 1;
private static final String TAG = "CategoryListActivity";
final Context context = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //listview = (ListView) findViewById(R.id.listview);
    mListAdapter = new ArrayAdapter<Category>(this, 
            android.R.layout.simple_list_item_1,
            android.R.id.text1,
            DataStore.categories);
    //listview.setOnItemClickListener(mOnItemClickListener);
    //listview.setAdapter(mListAdapter);
    setListAdapter(mListAdapter);       
    getLoaderManager().initLoader(LOADER_ID_CHECKS, null, this);   
}
@Override
protected void onListItemClick(ListView listView, View view, int position, long id) {
    Intent detailIntent = new Intent(this, ScreenSlideActivity.class);
    detailIntent.putExtra("category_id", id);
    startActivity(detailIntent);
}
@Override
public Loader<List<Category>> onCreateLoader(int id, Bundle args) {
    switch (id) {
        case LOADER_ID_CHECKS:              
            Loader<List<Category>> loader = new CategoryListLoader(this, url);
            loader.forceLoad();
            return loader;
    }
    return null;
}
@Override
public void onLoadFinished(Loader<List<Category>> loader, List<Category> result) {
    Log.d(TAG, "onLoadFinished");
    if (result != null) {
        Log.d(TAG, "items: " + result.size());
    }
    switch (loader.getId()) {
        case LOADER_ID_CHECKS:
            if (result != null) {
                for (Category category : result) {
                    DataStore.categories.add(category);
                }
            }   
            mListAdapter.notifyDataSetChanged();
            break;
    }
}
@Override
public void onLoaderReset(Loader<List<Category>> loader) {
    Log.d(TAG, "onLoaderReset");
    switch (loader.getId()) {
        case LOADER_ID_CHECKS:
            break;
    }
}        
}
 
 
