How to display HTML elements in an Android TextView?

0

I'm developing an Api that returns some texts, but these texts have tag HTML, be bold <b> or line <P> would like to know how best to print this in TextView , or if I have to sort the text before sending it to the API.

Remembering that I have control of the API and the client

    
asked by anonymous 22.03.2017 / 12:29

1 answer

1
  

[...] I would like to know what would be the best way to print this [...]

As for the best, this goes out of your need. You have no problem defining HTML text within your TextView . It would basically be this way:

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

See for the HTML class documentation.

    
22.03.2017 / 13:49