以编程方式滚动到一个特定的位置,在Android的ListView [英] Programmatically scroll to a specific position in an Android ListView
本文介绍了以编程方式滚动到一个特定的位置,在Android的ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何以编程方式滚动到特定位置的的ListView
?
How can I programmatically scroll to a specific position in a ListView
?
例如,我有一个的String [] {A,B,C,D ......}
,我需要设置的顶部可见项目的ListView
来的指数21我的的String []
。
For example, I have a String[] {A,B,C,D....}
, and I need to set the top visible item of the ListView
to the index 21 of my String[]
.
推荐答案
对于直接滚动:
getListView().setSelection(21);
对于平滑滚动:
For a smooth scroll:
getListView().smoothScrollToPosition(21);
这篇关于以编程方式滚动到一个特定的位置,在Android的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文