I am consuming the wordpress API and it returns the text in HTML format for example:
<p>Por Nora Moreno</p>
<p>Esta tarde el alcalde San Salvador, Ernesto Muyshondt, recibió a la ministra de Desarrollo Local, María Chichilco, para firmar un convenio de ejecución del programa de Emprendimiento Solidario. </p>
<p>“Tenemos el honor de subscribir este convenio de ejecución del Programa de Emprendimiento Solidario. Esperamos que con esta nueva administración poder llevar el FISDL a ser un ministerio”, dijo el mandatario. </p>
<p>De igual manera expreso que como alcaldía se comprometerán a trabajar en equipo. “Nos comprometemos a sumar esfuerzos para contribuir a este programa y beneficiar a los jóvenes de las comunidades que han sido declaradas como prioritarias en el Plan El Salvador seguro”, mencionó.</p>
The detail is that when formatting it in android with the function:
Html.fromHtml(Html.fromHtml(txtHtml).toString())
Me our former text without line breaks:
I have tried the following with no result:
String txtHtml = noticia.getCuerpo().replace("<p>","<br>");
String txtHtml = noticia.getCuerpo().replace("<p>","\n");
Your original text should render correctly using the method
Html.fromHtml(...)
:The problem is actually due to the fact that you only have to convert the string to its html representation and not carry out further conversions, since this is where information is being lost.
Do the following:
with this you will get the desired result:
Related:
TextView with two text colors in Android using Html.fromHtml()
Two-color ListView text