简体   繁体   English

滚动到顶部将listview项目移动到第二个位置

[英]scroll to top moves listview item to second position

As the question says, when I do either 正如问题所说,当我做任何一件事时

listview.smoothScrollToPositionFromTop(position, 0);

or 要么

listview.setSelectionFromTop(position, 0);

The item is scrolled to the second position in the list as opposed to the very top position. 该项目滚动到列表中的第二个位置,而不是最顶部的位置。 How do I get the item to scroll to the top position? 如何让项目滚动到顶部位置?

UPDATE UPDATE

For a bit of context, the following would work 对于一些上下文,以下将起作用

listview.smoothScrollToPositionFromTop(position+1, 0);

But I that would create tractability problems for me. 但我会为我创造易处理性问题。

Use listview.setSelection(int position) instead. 请改用listview.setSelection(int position)。 Also you can add OnScrollListener to your ListView for some more functionality. 您还可以将OnScrollListener添加到ListView以获得更多功能。 I have implemented it in my application. 我在我的应用程序中实现了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM