0

Do anyone know how to highlight a certain word in a TextView?

With highligt I mean to use an italic typeface for the word "Hua Hin" in the following string.

The sandy beaches of Hua Hin, popular resort town in Thailand.

Must I use a textView in another textView to acomplish this?

I set the text in the onPostExecute-method of AsyncTask:

protected void onPostExecute(Bitmap[] bitmap) { 
    for (int i = 0; i < nmbrOfImages; i++) {
       imageView[i].setImageBitmap(bitmap[i]);
       textView[i].setText(scrollText[i]);
       textView[i].setVisibility(TextView.VISIBLE);
    }
    loadAlertDialog();
 }

I have all my text in an xml-file

Björn Hallström
  • 3,654
  • 8
  • 38
  • 47

1 Answers1

1

If only italic you want then you can go for

textView[i].setText(Html.fromHtml(<i>some part</i> some other text);

else you can go for Spnnable

Here is an example in this answer.

Community
  • 1
  • 1
Android Killer
  • 17,747
  • 12
  • 64
  • 88