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);

我想在列表视图上显示数据bt此代码不起作用......有人对此有帮助......???

这是错误(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重命名你的primary key ColumnName to "_id"你没有扩展BaseAdapter所以你必须坚持他们already defined column name "_id"

于 2013-06-17T07:18:39.750 回答