我正在使用两个 SimpleCursorAdapter 在我的 Listview 中连续显示文本和图像。问题是当两次调用这些适配器时,它们会相互冲突。最后,我的 Listview 只显示了我最后调用的 SimpleCursorAdapter 的数据。
我需要做的是合并这两个 SimpleCursorAdapter,尽管它们使用不同的 sql 数据库。
有什么想法可以解决这个问题??
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.reminder_list);
    mDbHelper = new RemindersDbAdapter(this);
    mImageHelper = new ImageAdapter(this);
    mDbHelper.open();
    mImageHelper.open();
    fillData();
    fillImages();
    registerForContextMenu(getListView());
}
//
// Fills the ListView with the data from the SQLite Database.
//
private void fillData() {
    Cursor remindersCursor = mDbHelper.fetchAllReminders();
    startManagingCursor(remindersCursor);
    // Creates an array with the task title.
    String[] from = new String[] {RemindersDbAdapter.KEY_TITLE, RemindersDbAdapter.KEY_BODY};
    // Creates an array for the text.
    int[] to = new int[] {R.id.text1, R.id.text2};
    // SimpleCursorAdapter which is displayed.
    SimpleCursorAdapter reminders = new SimpleCursorAdapter(this, R.layout.reminder_row, remindersCursor, from, to);
    setListAdapter(reminders);
}
//
// Fills the ListView with the images from the SQLite Database.
//
private void fillImages() {
    Cursor imageCursor = mImageHelper.fetchAllImages();
    startManagingCursor(imageCursor);
    // Creates an array with the image path.
    String[] fromImage = new String[] {ImageAdapter.KEY_IMAGE};
    // Creates an array for the text.
    int[] toImage = new int[] {R.id.icon};
    // SimpleCursorAdapter which is displayed.
    SimpleCursorAdapter images = new SimpleCursorAdapter(this, R.layout.reminder_row, imageCursor, fromImage, toImage);
    setListAdapter(images);
}