Html.fromHtml不工作按要求 [英] Html.fromHtml not working as desired
本文介绍了Html.fromHtml不工作按要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
至于说, Html.fromHtml()
不工作。这里是一个需要显示HTML格式的字符串 -
这是code这我使用的用于显示文本
<$p$p><$c$c>holder.lblDesc.setText(Html.fromHtml(object.get(position).getProduct().getProductDescription()));在此先感谢:)
找到了解决办法
我从阿帕奇(公郎)下载库
并用这块code来显示它 -
字符串描述= StringEscapeUtils.unescapeHtml4(object.get(位置).getProduct()getProductDescription());
holder.lblDesc.setText(Html.fromHtml(介绍));
解决方案
请尝试以下操作:
的String = \"<p>vehethtehetggebebetbefbthtehethehetheth,ethethtehethethet<\\\\/p><p>ethetheyjyerjwehweryjetkteukejryjryje<\\\\/p>\"; TextView中的TextView =(的TextView)findViewById(R.id.textView);
textView.setText(Html.fromHtml(s.replace(与&amp;下;,&下;)替换(与&amp; gt;中,&gt;中)));
更新:
textView.setText(Html.fromHtml(Html.fromHtml(S)的ToString()));
您将得到的结果。
As said, Html.fromHtml()
is not working. Here is the string which needs to be displayed in html format -
<p>vehethtehetggebebetbefbthtehethehetheth,ethethtehethethet<\/p><p>ethetheyjyerjwehweryjetkteukejryjryje<\/p>
This is the code which I am using for displaying text
holder.lblDesc.setText(Html.fromHtml(object.get(position).getProduct().getProductDescription()));
This is what I get in display -
Thanks in advance :)
Found the solution
I have downloaded library from apache (commons lang) And used this piece of code for displaying it -
String description = StringEscapeUtils.unescapeHtml4(object.get(position).getProduct().getProductDescription());
holder.lblDesc.setText(Html.fromHtml(description));
And this is the result -
解决方案
Try the following:
String s = "<p>vehethtehetggebebetbefbthtehethehetheth,ethethtehethethet<\\/p><p>ethetheyjyerjwehweryjetkteukejryjryje<\\/p>";
TextView textView = (TextView) findViewById(R.id.textView);
textView.setText(Html.fromHtml(s.replace("<", "<").replace(">",">")));
UPDATE:
textView.setText(Html.fromHtml(Html.fromHtml(s).toString()));
You will get the result
这篇关于Html.fromHtml不工作按要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文