首页 > 如何使ListView滑动到指定的item的位置?

如何使ListView滑动到指定的item的位置?

现在要通过item的信息,使ListView定位到该item的位置,如何实现?


    smoothScrollToPosition(int position) 
    Smoothly scroll to the specified adapter position. // 滑动到适配器指定位置
    
    setSelection(int position) 
    Sets the currently selected item. // 设置当前选中位置
    

如果单纯的定位到指定位置,试试第一个方法


listView.setSelection(position);

position即你想要定位的item的位置。

【热门文章】
【热门文章】