[英]Android: Html.fromHtml() method weird issue
我面临一个奇怪的问题:
我的Html.fromHtml()源代码如下:
<strong>Terrible experience with Nikko hotel</strong><br />It was not easy to cancel booking. I called to cancel books, but they still chraged us two full days. A reason was we were late ten minutes in calling to cancel. They explained us very kindly that I can only cancel the first day. But they charged after then.\nSick."
这是从json响应中检索的
现在,当我使用setText显示它时,如下所示:
commentbox.setText(Html.fromHtml(cmnt.getString("cmnt")));
但我看到的输出如下:
为什么它给我斜体文字而不是粗体?
这可能是因为所描述的限制 在这里 :
Android中的Html.fromHtml()方法从HTML源创建一个SpannedString 翻转<em>
and <strong>
标签,因此您可能习惯以粗体显示的内容将变为斜体,反之亦然。 如果您在TextView中显示生成的HTML,这应该只是一个问题 - 特别是WebView应该表现得更正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.