1

データベースのすべての内容を画面に表示するリストビューを作成しました。私が使用しているコードはこれです

 private void fillData() {
// Get all of the notes from the database and create the item list
   Cursor c = datasource.getAllActs();
    startManagingCursor(c);
    String[] from = new String[] {DataBaseHelper.KEY_DATE,  
    DataBaseHelper.KEY_STEPS,DataBaseHelper.KEY_CALs };
    int[] to = { R.id.code, R.id.Days, R.id.BMI };
    SimpleCursorAdapter notes = new SimpleCursorAdapter (this, R.layout.notes_row, c,  from, to);
   setListAdapter(notes);               
 }

以下のコードで動作しました。

 private void fillData() {
            // Get all of the notes from the database and create the item list
            Cursor c = datasource.getAllGoals();
            startManagingCursor(c);
            String[] from = new String[] {DataBaseHelper.KEY_GOAL, DataBaseHelper.KEY_Current,DataBaseHelper.KEY_Target };
            int[] to = { R.id.code, R.id.Days, R.id.BMI };
            SimpleCursorAdapter notes = new SimpleCursorAdapter (this, R.layout.notes_row, c, from, to);
            setListAdapter(notes);              
     }

このコードに何か問題があり、見逃している可能性があるかどうか疑問に思っています。あなたがそれを必要とするなら、私はlogcatを持っています

4

1 に答える 1

1

私が考えることができる唯一のことは、あなたの new にCursorは という名前の列がないということ_idです。カーソル、

Cursor c = datasource.getAllActs();

クラスで必要なため_id、という名前の列があります。SimpleCursorAdapter

于 2012-05-24T22:48:28.587 に答える