Home Forum

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?
 

Related:

#1 Sambhaji kokate, Apr 5, 2017
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?
 
#2 LV426, Apr 5, 2017
no , I asked just to confirm and wanted to know is there any other way if array contain HTML tags
 
#3 Sambhaji kokate, Apr 5, 2017
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. [​IMG]

Code (Java):
  1.  
  2. String tmpHtml = "<html>a whole bunch of html stuff</html>";
  3. String htmlTextStr = Html.fromHtml(tmpHtml).toString();
  4.  
 
#4 bayk, Apr 7, 2017 Last edited: Apr 13, 2017