保存在ListView滚动位置 [英] Saving scroll position in the ListView
问题描述
可能重复:结果
<一href=\"http://stackoverflow.com/questions/3014089/maintain-save-restore-scroll-position-when-returning-to-a-listview\">Maintain/Save/Restore滚动位置返回到ListView 时
如何保存滚动ListView中的位置?我应该将元素添加到ListView中,进入任意位置的头,但视觉部分不应该被滚动。
how to save scroll position in the ListView? I should to add elements into the head of the ListView and into an arbitrary position, but visual part should NOT be scrolled.
比如我有123元,我看到指数66元素的1/2部分(要素有不同的高度)。我加一个元素到列表中,我应该看到索引67(previously指数66)元素的1/2部分。
for example I have 123 elements, I see 1/2 part of the element with index 66 (elements have a different height). I added an element into the list, and I should to see 1/2 part of the element with index 67 (previously index 66).
您可以看到为例 - 为默认的Windows Phone 7.5短信应用程序。此应用程序使用延迟加载
you can see as example - default "SMS" application for windows phone 7.5. This application uses the lazy-loading
推荐答案
您可以使用 getSelection()
和 setSelection()
法
使用获取当前的选择 getSelection()
,当你回来的ListView控件再次调用 setSelection()
Get the current selection using getSelection()
and when you comes back to that ListView again the call setSelection()
这篇关于保存在ListView滚动位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!