朋友们,
我在ListView中显示一个数组.
我在按钮点击和调用时动态更改数组的数据
adapter.notifyDataSetInvalidated();
Run Code Online (Sandbox Code Playgroud)
它不保持列表的滚动条位置.(列表中数据源的长度始终相同).任何人都可以指导我如何保持ListView的最后状态吗?
任何帮助,将不胜感激.
Fra*_*ita 10
试试这个:
//Get the top position from the first visible element
int idx = list.getFirstVisiblePosition();
View vfirst = list.getChildAt(0);
int pos = 0;
if (vfirst != null) pos = vfirst.getTop();
//Restore the position
list.setSelectionFromTop(idx, pos);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4199 次 |
| 最近记录: |