美文网首页
listview 精准跳转到某一个位置

listview 精准跳转到某一个位置

作者: heiheiwanne | 来源:发表于2016-08-18 17:46 被阅读262次

1.listview的跳转

// 保存当前第一个可见的item的索引和偏移量

intindex=mList.getFirstVisiblePosition();

Viewv=mList.getChildAt(0);

inttop=(v==null)?0:v.getTop();

// ...

//根据上次保存的index和偏移量恢复上次的位置

mList.setSelectionFromTop(index,top);

相关文章

网友评论

      本文标题:listview 精准跳转到某一个位置

      本文链接:https://www.haomeiwen.com/subject/ervmsttx.html