How to view HTML elements in an Android Textview?

Asked

Viewed 776 times

0

I am developing an Api that returns some texts, but these texts have tag HTML, is bold <b> or line <P> would like to know what would be the best way to print this in a TextView, or if I should tidy up the text before sending it to the API.

Remembering that I have API and client control

1 answer

2


[...]I wonder what would be the best way to print that[...]

The better way, this goes of its necessity. There is no problem in defining an HTML text within your TextView. It would be basically like this:

String htmlJsonText = "<h2>Titulo</h2><br><p>Descrição here</p>"; 
textViewHTML.setText(Html.fromHtml(htmlJsonText));

See more details in the documentation about the HTML class.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.