androidhtmlspanned

Parse HTML with Html.fromHtml


I have a TextView in my application and some HTML text.
This text contains symbols like "<" or ">" and HTML tags.

Here's a sample:

<P>very often (>1/10), often (>1/100, <1/10), not often (>1/1000, <1/100), rarely (>1/10000, <1/1000), very rarely (1/10000, including individual)</P>

I've tried to use Html.fromHtml method and it returns me an incorrect text:

very often (>1/10), often (>1/100, 1/1000, 1/10000),

My question is: how can I parse html using Html.fromHtml to avoid this situation?
Or is there any another ways to parse HTML?


Solution

  • Use &lt; (read: "less than") to replace <, and &gt; (read: "greater than") to replace >.