簡體   English   中英

Android:Html.fromHtml()方法奇怪的問題

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM