2014-10-28 65 views
0

是否有可能让SimpleCursorAdapter检索多个项目并让它们显示?这是从Android记事本教程(编辑了一下),当我试图让它拉AScoresDbAdapter.KEY_COL2_NAME, AScoresDbAdapter.KEY_COL1_DATE它只显示第一个在TextViewsetListAdapter多个项目?

是有原因还是我错过了什么?

private void fillData() { 
    // Get all of the notes from the database and create the item list 
    Cursor c = scoresDbAdapter.fetchAllNotes(); 
    startManagingCursor(c); 

    String[] from = new String[] { AScoresDbAdapter.KEY_COL2_NAME, AScoresDbAdapter.KEY_COL1_DATE}; 
    int[] to = new int[] { R.id.text1 }; 

    // Now create an array adapter and set it to display using our row 
    SimpleCursorAdapter notes = 
      new SimpleCursorAdapter(this, R.layout.shots_row, c, from, to,0); 
    setListAdapter(notes); 

} 

回答

0

好了,所以我想这溜递给我一开始他们是阵列,并且它可能把一个from一个int所以我加了另一个TextView和编辑上面这样:

String[] from = new String[] { AScoresDbAdapter.KEY_COL1_DATE,AScoresDbAdapter.KEY_COL2_NAME}; 
    int[] to = new int[] { R.id.text1, R.id.text2 }; 

现在它显示[Date][Name],而不是仅仅[Date][Name]

不知道这是否这种正确的做法,但如果有一个更好的我会很高兴为k现在呢。