tags:

views:

42

answers:

1

Html List tag not working in android textview. this is my string content:

String str="A dressy take on classic gingham in a soft, textured weave of stripes that resembles twill.  Take a closer look at this one.<ul><li>Trim, tailored fit for a bespoke feel</li><li>Medium spread collar, one-button mitered barrel cuffs</li><li>Applied placket with genuine mother-of-pearl buttons</li><li>;Split back yoke, rear side pleats</li><li>Made in the U.S.A. of 100% imported cotton.</li></ul>";

I loaded it on text view like this:

textview.setText(Html.fromHtml(str));

The Output like a paragraph.what can i do? Is there any Solution for it?

Edit:

webview.loadData(str,"texl/html","utf-8");
+2  A: 

As you can see in the Html class source code, Html.fromHtml(String) does not support all HTML tags. In this very case, <ul> and <li> are not supported.

From the source code I have build a list of allowed HTML tags:

  • br
  • p
  • div
  • em
  • b
  • strong
  • cite
  • dfn
  • i
  • big
  • small
  • font
  • blockquote
  • tt
  • monospace
  • a
  • u
  • sup
  • sub

So you better use WebView and its loadDataWithBaseURL method. Try something like this:

String str="<html><body>A dressy take on classic gingham in a soft, textured weave of stripes that resembles twill.  Take a closer look at this one.<ul><li>Trim, tailored fit for a bespoke feel</li><li>Medium spread collar, one-button mitered barrel cuffs</li><li>Applied placket with genuine mother-of-pearl buttons</li><li>;Split back yoke, rear side pleats</li><li>Made in the U.S.A. of 100% imported cotton.</li></ul></body></html>";
webView.loadDataWithBaseURL(null, str, "text/html", "utf-8", null);
Cristian
then what can i do to rectify it?
Praveen Chandrasekaran
Use a WebView then?
BrennaSoft
i used loadData method. It shows page cant found.
Praveen Chandrasekaran
very important to note some attributes of this "allowed" tags are not supported too. :=(
Jorgesys
what we have to do for it? do you mean just omit that?
Praveen Chandrasekaran
You just can't use it... it won't get rendered. As BrennaSoft suggested, use `WebView` instead.
Cristian
hey i already said this. It s not working in web view too.
Praveen Chandrasekaran
No, you have not said that, at least in this thread. Anyway, can you show us how you are trying to use `WebView` please?
Cristian
Oh yeah, I didnt mention the word web view. But i told i used the loadData method. its comes under webview class. Now its clear Right?
Praveen Chandrasekaran
Calm down... I edited my answer, please let me know whether it works.
Cristian
Yeah. Its Working. thanks a lot:)
Praveen Chandrasekaran