Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8706465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:37:14+00:00 2026-06-13T03:37:14+00:00

I am trying to add lists ( <ul> , <ol> ) to TextView. Usually

  • 0

I am trying to add lists (<ul>, <ol>) to TextView. Usually you load HTML to TextView with

textview.setText(Html.fromHtml("some String with HTML in it"));

but that does not work for all HTML tags. You can extend support for different tags with overriding default TagHandler and calling it with

textview.setText(Html.fromHtml("some String with HTML in it", null, new MyTagHandler()));

The question is: What does xmlReader in android.text.Html.TagHandler.handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) contain? Is it possible to get all <li> data for <ul> (or generally any element with it’s contents) somehow using

if (tag.equals("ul")) {
  // some call to xmlReader
}

And yes, I have seen those following threads already. I’m just looking for alternate solution.

  • Html List tag not working in android textview. what can i do?
  • Android: How to use the Html.TagHandler?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:37:16+00:00Added an answer on June 13, 2026 at 3:37 am

    The XMLReader is actually only an interface, and the methods it defines can be read from the API documentation.

    The ContentHandler that’s used to handle the SAX events in the Html class is known as Html.HtmlToSpannedConverter, which, in turn, uses its private handleStartTag(String,Attributes) method to handle the starting tags of HTML elements. Thus the list of out-of-the-box supported elements seems to be br, p, div, em, b, strong, cite, dfn, i, big, small, font, blockquote, tt, a, u, sup, sub, h1…h6 and img. Finally, if the tag is not recognized, the TagHandler given as a parameter to the HtmlToSpannedConverter is used, if it’s not null.

    The idea of a SAX handler is that you only get events from it: here’s a start tag, here’s a CDATA block, here’s an end tag, etc etc. The other way of handling an XML document is by using a DocumentBuilder to create a Document object of it. SAX parsers are used when you might have a large input stream which might not fit well into the memory, when you need to parse a document quickly or when you are receiving data from somewhere and want to parse it on the fly, before you have received all of it. Thus it is not possible to jump back and forth in an XML stream when using a SAX handler. So, to summarize an answer to your question “Is it possible to get all <li> data for <ul>“: no, unfortunately not.

    In your TagHandler you will probably want to emit a linebreak when you encounter a opening “ul” tag, then a “•” when you enter an opening “li” tag, and again linebreaks when you encounter a closing “li” or “ul” tag.

    If you need to support nested lists, you could add a counter to your TagHandler so that it increments each time you encounter an opening “ul” and decrements when a closing “ul” is encountered. Then you can add different amounts of indentation for the bullet points based on the counter of nested lists.

    Another way would be to create a stack of elements by adding an element to it when encountering an opening tag and removing it when encountering a closing tag. By going through the stack it would be easy to count the number of ancestor “ul” elements at any given time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a new entry into my database, but it's not working.
I´m trying to add a list to a table cell but there are no
Trying to add a class object into a List using reflection, but when invoking
Hi i'm trying to add a relative view to a merge adapter but it's
So i am trying to add TextView's into my main ListView within JAVA, And
I'm trying to add a header to the top of a ListView that is
i have problem with listview... i'm trying to add OnClickListener but in still doesn't
I am new to android development. I'm trying to have my string.xml file add
I'm trying to add vertical space between some sections of a page by adding
I'm trying to add a textview after a Listview (to the bottom of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.