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
In the practical on scrolling views, you use ScrollView to scroll a View or ViewGroup . ScrollView is easy to use, but it's not recommended for long, scrollable lists. RecyclerView is a subclass of ViewGroup and is a more resource-efficient way to display scrollable lists.
For these methods to work, the LayoutManager of the RecyclerView needs to have implemented these methods, and LinearLayoutManager does implement these in a basic manner, so you should be good to go. @SoliTawako I guess scrollTo(int x, int y) you can also scroll view, but in a more fine-tuned way.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With