1
SQLiteDatabase db = new MySQLiteOpenHelper(this).getReadableDatabase();
    String table = SQLContract.tables.Score.TABLE_NAME;
    String [] columns = {SQLContract.tables.Score._ID,SQLContract.tables.Score.COLUMN_NAME_player_Name,SQLContract.tables.Score.COLUMN_NAME_Score};
    String selection = null;
    String [] selectionArgs = null;
    String groupBy = null;
    String having = null;
    String orderBy = null;
    Cursor c = db.query(table, columns, selection, selectionArgs, groupBy, having, orderBy);
    int [] to = {android.R.id.text1};

    String [] from = { SQLContract.tables.Score.COLUMN_NAME_player_Name};
    SimpleCursorAdapter sca = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, c, from, to, SimpleCursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    setListAdapter(sca);

リストビューにデータを表示したいのですが、このコードは機能していません......これについて何か助けて....???

これはエラーです (1) そのような列はありません: _id

4

1 に答える 1

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

たとえば、主キー列の値を割り当てます"_id"

あなたが割り当てている方法

String [] from = { SQLContract.tables.Score.COLUMN_NAME_player_Name};

リストに表示しfromたい値を表示します。

リスト項目がクリックされたときに返す値をバインドしToます。

MoreOver Rename あなたprimary key ColumnName to "_id"は拡張していないBaseAdapterので、彼らの名前に固執する必要がありますalready defined column name "_id"

于 2013-06-17T07:18:39.750 に答える