I have a string array and was trying to style certain parts of the text with tags like < b>, < i>, ... but it doesn't work. The array looks like this:
<resources>
<array name="hour1">
<item>blabla\n<b>开发者_开发知识库blabla</b></item>
</array>
The text is displayed in the textview like this:
tTitel.setText(Html.fromHtml(Text[ii]));
I tried it without Html.fromHtml too but this had no effect. The styling tags do work if i use them directly in the code, like:
tTitel.setText(Html.fromHtml("blabla<b>blabla</b>");
Any ideas how to style the text in an array??
Cheers, Chris
You need to escape your HTML tags when they are included in an XML resource document. Instead of:
<b>
use:
<b>
At least, that works for ordinary string resources. I assume it works for string arrays.
精彩评论