Frage

Currently I m using TextView. I need to change the color of specific character in a string , as i have to work with localization so SpannableString won`t help me that much.

The string may be like this Hello please select at least 1 to move on now i would to change the text of just this specific "1" so that if it is converted to other language like french dutch the color of "1" wont get disturb with respect to its indexing.

How can i achieve this

P.S String is coming from R.String

Thank you

War es hilfreich?

Lösung

Just check this out:

myMsg.setText("Hello please select at least" +  Html.fromHtml("<font color='#FF0000'><b>1</b></font>"+"to move on"))

Andere Tipps

If your specific character is always the same in the different languages, you can use String.indexOf(String string) to get the position of the character and than use Spannableto format the String.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top