Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AutoCompleteTextView dropdown list text highlighted according to search text

I have implemented AutoCompleteTextView for the search field in my application.

I want to highlight the text entered in the AutoCompleteTextView(the search text field) to be highlighted in the drop down list. How can I do this?.

like image 474
sameer balouria Avatar asked Nov 01 '22 05:11

sameer balouria


1 Answers

So, In your getView method add the following

Spannable spanText = Spannable.Factory.getInstance().newSpannable(textString);
spanText.setSpan(new BackgroundColorSpan(0xFFFFFF00), startIndex, endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
myTv.setText(spanText);
like image 180
R9J Avatar answered Nov 15 '22 06:11

R9J