bigdestroyer bigdestroyer - 1 year ago 105
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?

Answer Source

Try changing it to :

<string name="title_label"><![CDATA[<b>Title</b>]]> %s</string>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download