android listview第一个可见位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2041300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
android listview first visible position
提问by Arutha
How can I change the first visible item in a list view (I searched a method such as setFirstVisiblePosition) ?
如何更改列表视图中的第一个可见项(我搜索了 setFirstVisiblePosition 等方法)?
采纳答案by Dave Webb
Have a look at this question.
看看这个问题。
回答by Samuh
ListView.getFirstVisiblePosition()
Returns the position within the adapter's data set for the first item displayed on screen. Once you have the position, you can alter the item at that position in your adapter.
ListView.getFirstVisiblePosition()
返回屏幕上显示的第一个项目在适配器数据集中的位置。获得位置后,您可以更改适配器中该位置的项目。
Presume my Adapter is binding a String[] to a ListView. I can use getFirstVisiblePosition()
method on the listview instance, which will return the index/position of the first visible item, I can then change my String item at the "index"th position and alter the list.
假设我的适配器将 String[] 绑定到 ListView。我可以getFirstVisiblePosition()
在 listview 实例上使用方法,该方法将返回第一个可见项目的索引/位置,然后我可以在“index”th 位置更改我的 String 项目并更改列表。