开发者

How to style text in a string array?

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:

&lt;b&gt;

At least, that works for ordinary string resources. I assume it works for string arrays.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜