Android : How to espape a 'greater than sign' in Html.fromHtml() which is understood as start tag instead of greater than sign
Asked Answered
C

1

0

I have a problem with Html.fromHtml which interprets "<" as a start tag and not as a "greater than" sign.

Is there a way to escape the "<" sign so it is displayed ?

Ex :

Html.fromHtml("<b>Test</b> : 10", Html.FROM_HTML_MODE_LEGACY)

Gives Test : 10

Html.fromHtml("<b>Test</b> : >10", Html.FROM_HTML_MODE_LEGACY)

Gives Test : >10

but

Html.fromHtml("<b>Test</b> : <10", Html.FROM_HTML_MODE_LEGACY)

Gives Test :

Carl answered 5/11, 2019 at 19:46 Comment(1)
Use &lt; instead of <Drolet
E
0

You have to use &lt; to show < using Html.

Html.fromHtml("<b>Test</b> : &lt;10", Html.FROM_HTML_MODE_LEGACY)
Eva answered 5/11, 2019 at 20:2 Comment(2)
Thank you. This was not referenced as a supported tag but it seams to work well.Carl
You are welcome @Nathalie. Also press upvote so that others can find it helpful.Eva

© 2022 - 2024 — McMap. All rights reserved.