我在 ListActivity 中显示来自 SQLite 的数据。用户可以单击列表元素,将他发送到更新数据库的活动。
更新 Activity 完成后,用户将被送回原始 ListActivity。
当用户从 ListActivity 回来时,我希望将 ListView 定位为显示她刚刚更新的数据(例如,在可能的第一个位置)。
我尝试将光标定位到我要显示的条目;但这似乎不起作用(有关代码示例,请参见下面的代码)。
protected void onResume() {
super.onResume();
mDbCursor = mDbAdapter.getCursor();
long id = getIntent().getLongExtra(FIRST_ID, -1); // Id of updated row.
while (mDbCursor.moveToNext() && getId(mDbCursor) != id) {
}
.
. calling setListAdapter(SimpleCursorAdapter);
.
}
我确实认为退出while循环后光标定位到正确的行。