0

SimpleCursorAdapter を介してデータベースから ListView にデータを配置しようとすると、ListView の行が表示されますが、空です。

お気に入り:

[ _ _ _ _ _ ____ ]

[ _ _ _ _ _ ____ ]

[ _ _ _ _ _ ____ ]

それ以外の:

[文章]

[文章]

[文章]

私のコード:

    db = provider.getReadableDatabase();
    String[] columns = {"_id", "Title"};
    Cursor cursor = db.query(NotificationsProvider.TABLE_NAME, columns, null, null, null, null, null);
    Log.d(TAG, "COUNT: "+cursor.getCount());
    String[] clm = {"Title"};
    int[] to = {android.R.id.list};
    cursorAdapter = new SimpleCursorAdapter(this,
            android.R.layout.simple_list_item_1,
            cursor, clm, to, 0);

    setListAdapter(cursorAdapter);

ありがとう!

4

1 に答える 1

1

あなたは単に間違ったIDを使用しています。試してください:

int[] to = {android.R.id.text1};

(自分自身をチェックアウトしsimple_list_item_1.xmlて、適切な ID を確認できます。)

于 2013-01-14T19:56:29.857 に答える