回收站视图滚动到特定位置 [英] Recycler view scroll to specific position

查看:94
本文介绍了回收站视图滚动到特定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有带有View Holder的自定义recyclerview.我有一个searchview.我想根据searchview搜索的文本移动回收站视图的位置.我该如何完成这项任务?这样搜索文字过滤器就会执行,并根据过滤条件,我会得到过滤后的文本的位置.并使用它可以将焦点(滚动)移动到该位置.

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.

谢谢

推荐答案

尝试一下:

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);

这篇关于回收站视图滚动到特定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆