是否可以SimpleCursorAdapter
检索多个项目并显示它们?这是来自Android记事本教程(编辑了一下),当我尝试拉它AScoresDbAdapter.KEY_COL2_NAME, AScoresDbAdapter.KEY_COL1_DATE
时,它只显示TextView
有这个原因还是我错过了什么?
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 :(得分: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]
不确定这是否正确,但如果有更好的方法,我会很高兴知道它。