I have an XML file in res/values
with a string array, whose items contains simple HTML markup, such as:
<resources>
<string-array name="frases31">
<item>They <u>were not</u> before.</item>
<item>I don\'t think <u>he</u> is.</item>
...
I load these into a String[]
array this way:
Resources res = mContext.getResources();
exercise.setSentences(res.getStringArray(R.array.frases31));
The trouble is the String[]
array in variable exercise
, which is called sentences
contains only the strings, the HTML markup (<u>
and </u>
) has disappeared.
Should I store the result of calling res.getStringArray(R.array.frases31)
in a special variable?
I have an index and I will put sentences[i]
in a TextView
programmatically.
You'll need to edit the XML to achieve this. You can wrap your items with CDATA to preserve the markup:
Or escape each markup character individually: