0

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

4

3 回答 3

1

如果您的特定字符在不同语言中始终相同,则可以使用String.indexOf(String string)来获取字符的位置,而不是使用Spannable来格式化字符串。

于 2013-04-24T06:48:07.713 回答
1

看看这个:

myMsg.setText("Hello please select at least" +  Html.fromHtml("<font color='#FF0000'><b>1</b></font>"+"to move on"))
于 2013-04-24T06:48:44.557 回答
-1

你必须使用 ForegroundColorSpan,http://developer.android.com/reference/android/text/style/ForegroundColorSpan.html

于 2013-04-24T06:52:05.547 回答