Android - Highlight a Word In a TextView?

后端 未结 9 1792
予麋鹿
予麋鹿 2020-12-07 15:57

I have a database search query which search in the database for a word entered by the user and return a Cursor.

In my ListActivity

9条回答
  •  甜味超标
    2020-12-07 16:26

    insert HTML code for color around word and set it to your textView .

    like

    String newString = oldString.replaceAll(textToHighlight, ""+textToHighlight+"");
    textView.setText(Html.fromHtml(newString));
    

提交回复
热议问题