Show <ul> <li> in android textview Show <ul> <li> in android textview android android

Show <ul> <li> in android 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("\n");            if(tag.equals("li") && opening) output.append("\n\t•");    }}

and

textView.setText(Html.fromHtml(myHtmlText, null, new UlTagHandler()));


Tags Supported in String Resources

Tags in static string resources are parsed by android.content.res.StringBlock, which is a hidden class. I've looked through the class and determined which tags are supported:

<a> (supports attributes "href")<annotation><b><big><font> (supports attributes "height", "size", "fgcolor" and "bicolor", as integers)<i><li><marquee><small><strike><sub><sup><tt><u>

Tags Supported by Html.fromHtml()

For some reason, Html.fromHtml() handles a different set of of tags than static text supports. Here's a list of the tags (gleaned from Html.java's source code):

<a> (supports attribute "href")<b><big><blockquote><br><cite><dfn><div><em><font> (supports attributes "color" and "face")<i><img> (supports attribute "src". Note: you have to include an ImageGetter to handle retrieving a Drawable for this tag)<p><small><strong><sub><sup><tt><u>

see this link for more details


see HTML Tags Supported By TextView both ul and li tags are not Supported by android.text.Html class.

SOLUTION : you can display these tags using WebView or by TagHandler

for more help see this post:

Html List tag not working in android textview. what can i do?