Machael.HW.Wong
Machael.HW.Wong

Reputation: 169

How can I show out "<>" using HTML.from() in TextView?

May I know if there have any way to show out "<>" or something like "<>ddd" normally using HTML.from() in textview?

the character is all missing after that invalid HTML tag ...

Upvotes: 0

Views: 63

Answers (2)

Jorge Arimany
Jorge Arimany

Reputation: 5882

you should escape the characters, < is &lt; (Less Than) and > is &gt; (Greater Than) so:

textView.setText(Html.fromHtml("&lt;&gt;ddd"));

will output

output

Upvotes: 0

Max Zavernutiy
Max Zavernutiy

Reputation: 1879

Use &lt; for < and &gt; for >
For example textView.setText(Html.fromHtml("<h1>Hello &lt;World&gt;</h1>"));
This results in Hello <World>

Upvotes: 1

Related Questions