Recycler view scroll to specific position

▼魔方 西西 提交于 2019-12-22 07:23:08

问题


I have custom recyclerview with view Holder. I have one searchview. I want to move recycler view position as per searchview searched text. How can I achieve this task? so that search text filter will perform and according to filteration I will get position of filtered text. and using that I can move my focus (scroll) to that position.

Thank you


回答1:


Try this:

myRecyclerview.scrollToPosition(position);

if not works in some cases(Keyboard opening etc.), try using delay.

new Handler().postDelayed(new Runnable() {
    @Override
    public void run() {
         myRecyclerview.scrollToPosition(position);
    }
 }, 200);


来源:https://stackoverflow.com/questions/43829419/recycler-view-scroll-to-specific-position

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!