android - 设置ListView在android中 "item edited"位置右显示

标签 android listview

我在列表中选择一个项目进行编辑(我使用上下文菜单),然后填充数据以“刷新”列表,我的列表将以“自上而下”的顺序显示。我想在我刚刚编辑的项目的位置显示我的列表(我不必向下拖动滚动条来找到它)。那么,我该怎么做呢?

最佳答案

使用 ListView.setSelection(int position) 方法。它将选择指定位置的列表项,但前提是不在触摸模式下。如果在触摸模式下,它只会滚动到指定的位置,以便 position 的项目是屏幕上的第一个。

来自 http://d.android.com/ :

Sets the currently selected item. If in touch mode, the item will not be selected but it will still be positioned appropriately. If the specified selection position is less than 0, then the item at position 0 will be selected.

关于android - 设置ListView在android中 "item edited"位置右显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1345875/

相关文章:

java - FitViewport 中的 LibGDX 背景图像

java - PayPal Cordova 插件不适用于电子邮件地址

java - 以java快速方式写入/读取 float 组

flutter - 有没有办法在包含 ListView 的 flutter 中关闭模态底部工作表?

c# - 来自 Binding ElementName 的值生成空字符串

android - 动态改变 ImageView 的图像

JavaMail API 不适用于移动数据但适用于 Wifi

android - setFastScrollEnabled 在我的所有手机上都能正常工作,但在 Honeycomb 平板电脑上会崩溃

c# - ListViewItem 边框 - 紧凑型框架

android - 通过简单的适配器在 ImageView 中显示位图图像