Android应用程序无法很好地呈现html标记 [英] Android app not rendering html tags very well

查看:133
本文介绍了Android应用程序无法很好地呈现html标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我从字符串中的web服务获得的。

 & lt; p& gt;& lt; strong& gt;这是指导者' s回复宾客的MDB讯息& lt; / strong& gt;& lt; / p& gt; 

这就是我将它设置为文本视图的方式。

 字符串回复= parent.getString(TAG_ReplyMessage); 
TextView ReplyTextView =(TextView)findViewById(R.id.reply_txt);
ReplyTextView.setText(Html.fromHtml(Reply));

但应用程序显示的信息包含< p> < strong> 标签。

p>

鉴于它应该呈现这些标签,而不是显示它的html。



任何帮助将不胜感激。

解决方案
我的项目中也出现同样的问题,可能会帮助你:

 字符串回复= parent.getString(TAG_ReplyMessage); 
TextView ReplyTextView =(TextView)findViewById(R.id.reply_txt);
String htmltext = Html.fromHtml(Reply).toString();
ReplyTextView.setText(Html.fromHtml(htmltext));


This is what i am getting from web service in string.

&lt;p&gt;&lt;strong&gt;This is instructor&amp;#39;s reply to the guest&amp;#39;s MDB message&lt;/strong&gt;&lt;/p&gt;

This is how i am setting it to text view

String Reply = parent.getString(TAG_ReplyMessage);
TextView ReplyTextView= (TextView) findViewById(R.id.reply_txt);
ReplyTextView.setText(Html.fromHtml(Reply));

but app shows information with <p> and <strong> tags.

Whereas it should render those tags, not to display it's html.

Any help would be highly appreciated.

解决方案

It may help you I was also getting same issue in my project and this worked for me.may be it will help you:

String Reply = parent.getString(TAG_ReplyMessage);
TextView ReplyTextView= (TextView) findViewById(R.id.reply_txt);
String htmltext=Html.fromHtml(Reply).toString();
ReplyTextView.setText(Html.fromHtml(htmltext));

这篇关于Android应用程序无法很好地呈现html标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆