[英]Android: Html.fromHtml() method weird issue
I am facing a weird issue: 我面临一个奇怪的问题:
My source string for Html.fromHtml() is as follows: 我的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."
which is retrieved from a json response 这是从json响应中检索的
Now, when I display it using setText as follows: 现在,当我使用setText显示它时,如下所示:
commentbox.setText(Html.fromHtml(cmnt.getString("cmnt")));
but the output which i see is as follows: 但我看到的输出如下:
Why is it giving me italic text instead of bold? 为什么它给我斜体文字而不是粗体?
This can be a LIMITATION as described here : 这可能是因为所描述的限制 在这里 :
the Html.fromHtml() method in Android that creates a SpannedString from HTML source flips <em>
and <strong>
tags, so what you might be used to seeing in boldface turns into italics and vice-versa. Android中的Html.fromHtml()方法从HTML源创建一个SpannedString 翻转<em>
and <strong>
标签,因此您可能习惯以粗体显示的内容将变为斜体,反之亦然。 This should only be an issue if you are displayng the generated HTML in a TextView — WebView in particular should behave more normally. 如果您在TextView中显示生成的HTML,这应该只是一个问题 - 特别是WebView应该表现得更正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.