bigdestroyer bigdestroyer - 2 months ago 9x
Android Question

Formatting CDATA string shows unexpected character

I have this string entry:

<string name="title_label">[<![CDATA[<b>Title</b>]]> %s</string>

and I format it this way:

String titleLabel = getString(R.string.title_label);
Spanned title = Html.fromHtml(String.format(titleLabel, "My Title"));

However, it shows:

[Title My Title

instead of:

Title My Title

Why is it showing the '[' character in the beginning?


Try changing it to :

<string name="title_label"><![CDATA[<b>Title</b>]]> %s</string>