12

I have a problem. I want to put in to the "TextView" html format text. I add the like below.

<string name="text"><![CDATA[<table><tr><th bgcolor= #FF0000>some text</th></tr> <tr><td bgcolor= #FF0000> some text</td></tr>]]></string>

and put it into the TextView as:

mInfoText.setText(Html.fromHtml(getString(R.string.text)));

but after run application, displayed text in TextView is not formatted.

monawi
  • 163
  • 1
  • 2
  • 8

2 Answers2

12

Android TextView doesn't support the Table tag and that's the reason you can't see it in a formatted way. You must use a WebView for this purpose.

To know what are the tags supported check this Html List tag not working in android textview. what can i do?

Community
  • 1
  • 1
Andro Selva
  • 53,910
  • 52
  • 193
  • 240
3

try whit WebView

String html = "<table><tr><th>text1</th></tr><tr><td>text2</td></tr></table>";
webView.loadDataWithBaseURL(null, html, "text/html", "utf-8", null);
Vasil Valchev
  • 5,701
  • 2
  • 34
  • 39