I have a string in my resource:
<string name="region"><b>Region:</b> %1$s</string>
I am trying to set this text to a textview:
tvRegion.setText(Html.fromHtml(R.string.region, "France"));
The problem is that the string "region" is not bold !
From the official documentation:
Sometimes you may want to create a styled text resource that is also used as a format string. Normally, this won't work because the
String.format(String, Object...)method will strip all the style information from the string. The work-around to this is to write the HTML tags with escaped entities, which are then recovered withfromHtml(String), after the formatting takes place.
You need to HTML-escape the opening bracket of html tags, when inserting it in any xml resource file.
<string name="region"><b>Region:</b> %1$s</string>
bis escaped?