Just check this out:
myMsg.setText("Hello please select at least" + Html.fromHtml("<font color='#FF0000'><b>1</b></font>"+"to move on"))
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
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 Spannable
to format the String.
you have to use ForegroundColorSpan, http://developer.android.com/reference/android/text/style/ForegroundColorSpan.html