【问题标题】:Android: String from SQLite can not be set as HTML in TextviewAndroid:来自 SQLite 的字符串不能在 Textview 中设置为 HTML
【发布时间】:2018-12-07 01:40:34
【问题描述】:

您好,我收到了来自后端 API 的 HTML 字符串格式的响应,我在 android 中将 textview 作为 HTML 放入:

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
     sinopsis.setText(Html.fromHtml(summaryText, Html.FROM_HTML_MODE_COMPACT));
}else{
     sinopsis.setText(Html.fromHtml(summaryText));
}

问题是:

如果我将来自 API 的响应直接放入 Textview,则结果正确显示为 HTML 解析为 <br/>,   标签未显示为 html 代码

Hi this is example from API response
Thanks

但如果我将结果作为字符串保存到 SQLite 并进入显示为纯 html 代码的 Textview

Hi this is example from API response <br />Thanks

我不知道如何解决这个问题,请任何人帮助我。

【问题讨论】:

  • 已解决:我对字符串使用了替换功能

标签: java android html sqlite textview


【解决方案1】:

已解决:我将一些 html 翻译成 Android 中的字符串函数,例如
成 \n

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-10
    • 1970-01-01
    • 1970-01-01
    • 2013-07-28
    • 1970-01-01
    • 2019-05-24
    相关资源
    最近更新 更多