Android:Html.fromHtml()方法奇怪的问题

时间:2011-11-25 07:08:49

标签: android textview

我面临一个奇怪的问题:

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")));

但我看到的输出如下:

enter image description here

为什么它给我斜体文字而不是粗体?

1 个答案:

答案 0 :(得分:8)

这可以是 LIMITATION ,如here所述:

Android中的Html.fromHtml()方法,从HTML源翻转<em> and <strong>标记创建一个SpannedString,以便您可能习惯以粗体显示斜体,反之亦然。如果您在TextView中显示生成的HTML,这应该只是一个问题 - 特别是WebView应该表现得更正常。

相关问题