-3

我有一个字符串,如下所示

<p><strong>Lorem Ipsum is simply dummy text</strong></p>
<table border="0">
<tbody>
<tr>enter code here
<td>
<ul>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>
<li>Ut imperdiet tortor sit amet enim bibendum eget fermentum lectus auctor.</li>
<li>Cras mattis mi nec dolor iaculis a rhoncus ligula lacinia.</li>
<li>Phasellus sit amet lorem ut nunc iaculis lacinia nec at diam.</li>
<li>Duis nec turpis ac diam vehicula malesuada.</li>
</ul>
</td>
<td>
<ul>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>
<li>Ut imperdiet tortor sit amet enim bibendum eget fermentum lectus auctor.</li>
<li>Cras mattis mi nec dolor iaculis a rhoncus ligula lacinia.</li>
<li>Phasellus sit amet lorem ut nunc iaculis lacinia nec at diam.</li>
<li>Duis nec turpis ac diam vehicula malesuada.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse interdum sem ante, scelerisque vehicula libero. Sed porttitor tincidunt lacus, et lacinia mauris placerat at. Fusce laoreet scelerisque turpis sit amet dignissim. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc mollis, urna sed adipiscing posuere, erat orci facilisis neque, quis fringilla ipsum neque ut libero. Sed eget arcu massa, sodales fermentum lorem. Morbi fringilla commodo magna lobortis porttitor. Etiam tortor elit, cursus non placerat vel, dapibus vitae velit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam euismod nisl vitae orci viverra imperdiet.</strong></p>

我想在没有 HTML 标记的情况下显示所有这些。

请帮助我......如果可以的话,请建议我以任何方式做。

4

4 回答 4

1

尝试使用Html.fromHtml(yourHtml)..
http://developer.android.com/reference/android/text/Html.html

于 2012-07-17T11:05:02.500 回答
1

首先用真正的 HTML 制作它,即 <> 然后用正则表达式删除 HTML 标签。

mTextView.setText(HTML.fromHtml("&lt;p&gt;&lt;strong&gt;L...." ));
String regexNoHTML = "\\<.*?\\>";    
String finalStringNoHTML = mTextView.getText.replaceAll(noHTMLString, "");
mTextView.setText(finalStringNoHTML);
于 2012-07-17T11:09:13.240 回答
0

嗨,您可以像下面这样分配

txtUpgrade.setText(Html.fromHtml(getString(R.string.upgrade_text)));
于 2012-07-17T11:09:20.633 回答
0

首先将您的字符串值存储到一个变量中,然后使用下面的代码将此字符串显示到 textview 中。

String s="&lt;li&gt;Duis nec turpis ac diam vehicula malesuada.&lt;/li&gt;";
mTxtView1.setText(Html.fromHtml(s));
于 2012-07-17T11:09:48.830 回答