【发布时间】:2012-06-24 08:02:56
【问题描述】:
我创建了一个列表视图来在屏幕上显示数据库的所有内容。我使用的代码是这样的
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
【问题讨论】:
-
忘记logcat...从你的帖子我什至无法判断问题是什么。
-
请发布 logcat 错误,如果 Alex 没有猜到,我们可以看看问题出在哪里。
标签: android sqlite android-listview