0

Issue with StringBuilder

I have used the table tag in sb.append but it is not showing table can any one help me out of this?

StringBuilder sb = new StringBuilder();
sb.append("<table><tr><td>A</td>  <td>B</td>  <td>C</td> </tr><tr><td>X</td>  <td>Y</td>  <td>Z</td> </tr></table> ");

Spanned mainContent = Html.fromHtml(sb.toString());

Log.d(TAG_ID, ""+mainContent);

2 Answers 2

2

This is not a problem with StringBuilder. Html.fromHtml doesn't handle all tags, just certain ones for text formatting. If you want to display complete HTML, use a WebView.

Sign up to request clarification or add additional context in comments.

1 Comment

hi can u explain how to use this please
1

Currently Html.fromHtml doesn't supports <table> tag..

Supported HTML's tag from Html.fromHtml are...

<a href="...">
<b>
<big>
<blockquote>
<br>
<cite>
<dfn>
<div align="...">
<em>
<font size="..." color="..." face="...">
<h1>
<h2>
<h3>
<h4>
<h5>
<h6>
<i>
<img src="...">
<p>
<small>
<strike>
<strong>
<sub>
<sup>
<tt>
<u>

If you want to use <table> tag then you can use Android WebView and then method

String summary = "<html><body>You scored <b>192</b> points.</body></html>";
webview.loadData(summary, "text/html", null);

also similar method...

loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, String historyUrl)

Load the given data into the WebView, using baseUrl as the base URL for the content.

1 Comment

i want to send the appended dATA to facebook as a string how can i store the webview data in string

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.