how do I highlight the searched text in my search filter?

后端 未结 5 2369
无人及你
无人及你 2020-12-09 12:27

I am trying to do a search such that all the \"visible\" search letters should be highlighted. I tried using spannable but that didn\'t do the trick, maybe I wasnt doing it

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 12:33

    Put this code before setting text in getview

    Spannable wordtoSpan = new SpannableString("Your_text_in_getviews");
    
            wordtoSpan.setSpan(new ForegroundColorSpan(Color.RED), 0, edtFilter
                    .getText().toString().length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    txt_contact.setText(wordtoSpan);
    

提交回复
热议问题