I have String with ul and li in it. And I am trying to show them in HTML formatting in textview. textView.setText(Html.fromHtml(myHtmlText));
But textview shows the plain text. How can I have the ul and li tags formatted in textview?
I have String with ul and li in it. And I am trying to show them in HTML formatting in textview. textView.setText(Html.fromHtml(myHtmlText));
But textview shows the plain text. How can I have the ul and li tags formatted in textview?
You can use Html.TagHandler.
In your case it will be like this:
public class UlTagHandler implements Html.TagHandler{
@Override
public void handleTag(boolean opening, String tag, Editable output,
XMLReader xmlReader) {
if(tag.equals("ul") && !opening) output.append("
");
if(tag.equals("li") && opening) output.append("
?");
}
}
and
textView.setText(Html.fromHtml(myHtmlText, null, new UlTagHandler()));