I’ve got the following problem: I’m trying to highlight text in multiple EditText controls simultaneously by calling viewXYZ.setSelection(int, int), but the selection is only visible on the focused view.
Is there any way to bypass this, to highlight text in an unfocused EditText? Maybe by overloading the onDraw() methods?
EditText supports
Spannableobjects, so you can apply highlights to text (e.g., background colors) yourself.This sample project demonstrates a search field that applies a background color to a larger piece of text based upon the search results. The key part is the
searchFor()method:Note, though, that your “output string” probably should be a
TextView, not anEditText.EditTextis for input, not output.