• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to access string-array if it contain HTML tags

I have following code in resources/arrays.xml file

<resources>
<string-array name="myarray">
<item>Physical World \n What Is Physics</item>
<item><b>Scope And Excitement Of Physics</b></item>
<item><b>Physics,Technology And Society</b></item>
</resources>
to access myarray we can use
String[] str = getResources().getStringArray()(R.arrays.myarray);
but this array contains html tags like <b></b>,<u></u>. how should i access this array?
 
HTML tags are still just characters, so you access the string array in exactly the same way.
Why do you ask? Is it causing problems?
 
Yes, there is a way to parse HTML. Let's say you have complicated HTML and you want to print it as a string nicely.

Java:
String tmpHtml = "<html>a whole bunch of html stuff</html>";
String htmlTextStr = Html.fromHtml(tmpHtml).toString();
 
Last edited:
Back
Top Bottom