0

You suppose in simple recyclerview i have some text, i'm trying to find how can i search text in that and scroll to found text position, for example in simple recyclerview i have 10 row and on 4th position i have this text:

Hello World

i want to scroll to that on 4th position, how can i do that?

3
  • On Arraylist of Adapter, whether that particular item is in the list or not, if its there, perform Cuatom search operation, on the arraylist index Item, if you found than take that position and programatically scroll recyclerview to that index Commented Feb 27, 2017 at 17:46
  • @LovekushVishwakarma and what about if recylerview is big and text is middle of that? Commented Feb 28, 2017 at 3:04
  • What about means? asking about focus or how to find sir? if your list is too big, than use exponential series to find your string. Commented Feb 28, 2017 at 10:50

3 Answers 3

1

Check your RecyclerView items for their texts, once you have a match to your desired text, get the item position and call:

myRecyclerview.scrollToPosition(position); 
Sign up to request clarification or add additional context in comments.

2 Comments

and what about if recylerview is big and text is middle of that?
Thats something you need to test yourself to check either if it works as you want or not but you can also check this answer for stackoverflow.com/questions/26875061/…
0

Iterate through your Adapter's data list and store the index for the item you're searching for. Then, use RecyclerView's scrollToPosition(y) method with that index to scroll to that particular item's position.

Comments

0

Workaround that I found on stackoverflow which really worked for me

myRecyclerView.scrollToPosition(position); new Handler().postDelayed(new Runnable() { @Override public void run() { myRecyclerView.smoothScrollToPosition(position); } }, 50); //sometime not working, need some delay 

https://stackoverflow.com/a/57207024/6940711

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.