当前,填充时的列表是从列表底部的 View 开始的。有没有办法使用 listAdapters 将其强制到列表顶部?
目前,创建时方向滚动到底部。有没有办法在创建时将屏幕固定到顶部? /image/TR9S4.jpg在此示例中,您会看到创建时的条目 1 向上推,为六个条目腾出空间...相反,我希望它像这样填充。 /image/Pu7n3.jpg ...条目 1 是列表的顶部,条目 6 被推到底部以进行滚动。
如果您查看上面的图片,您会发现它从列表底部而不是顶部开始。有什么想法吗?
mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mStrings);
setListAdapter(mAdapter);
registerForContextMenu(getListView());
populateFields();
private void populateFields() {
if (mRowId != null) {
Cursor note = mDbHelper.fetchDaily(mRowId);
startManagingCursor(note);
String body = note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_DBODY));
mAdapter.clear();
if (!(body.trim().equals(""))){
String bodysplit[] = body.split(",");
for (int i = 0; i < bodysplit.length; i++) {
mAdapter.add(bodysplit[i].trim());
}
}
}
}
**已编辑以修复 != 字符串错误。
最佳答案
您希望列表中后面的项目位于 ListView
的顶部吗?如果是这样,请查看以下问题:Is it possible to make a ListView populate from the bottom?
关于java - Android ListAdapter 启动@top,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13808685/