我有简单的 HTML
< H2>标题< / H>< BR>
&其中; P>此处描述&所述; / P>
我要显示在的TextView
HTML样式的文本了。如何做到这一点???
任何帮助将是AP preciated。
解决方案您需要使用Html.fromHtml()在你的XML字符串使用HTML。简单地引用与HTML中的字符串在布局XML将无法工作。
例如:
myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description此处&lt; / P&gt;中));I have simple HTML:
<h2>Title</h2><br>
<p>description here</p>
I want to display HTML styled text it in TextView
. How to do this???
Any help would be appreciated.
解决方案You need to use Html.fromHtml()
to use HTML in your XML Strings. Simply referencing a String with HTML in your layout XML will not work.
For example:
myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>"));