This is propably just idea issue.
I have many textViews in one ScrollLayout (so let’s say only half of them are showed at one moment on screen). Then I have an editText and I am thinking of a way how to highlight & scroll to the textView which contains same string value as user wrote in editText.
For instance :
editText.text = "Test"
textView.text = "Testing Issue"
textView2.text = "Bla Bla"
I want to highlight the part/full(doesnt matter) textView with the corresponding text value.
Many thanks in advance and sorry if my question is lame 🙂 as I am new to Android.
In this case I’d recommend using a ListView, and have a separate row for evey text segment you have.
You assign a TextWatcher for the EditText, it has a callback that gets called after every letter typed in. In this callback, you do you search for the entered string (possibly asynchronously), and get back the positions of the rows that contain the specified substring.
Now to scroll the ListView to the first occurence, you can use its .smoothScrollToPosition() method.
As for the highlights, you probably view the texts in the rows using TextView widgets. You can set the text viewed inside these with .setText(), which accepts Spannable/Spanned objects as well. These are strings on steroids, you can assign style spans on different regions of the strings. So you can use this to e.g. show the substring you’ve found in a different colour/background/etc.
Or use html. Html.fromHtml() actually processes the html tags in the provided strings into a Spannable objects, so it may be easier to work with 🙂