不推荐使用Html.fromHtml(),替代品是什么? [英] Html.fromHtml() is deprecated, what is the alternative?
问题描述
我已更新为SDK版本24,现在已弃用Html.fromHtml()
. Html类提供了一个带有额外参数的新方法,该方法名为flag,但最小API为24.
I updated to the SDK Version 24 and now Html.fromHtml()
is deprecated. And the Html class has a a new method with extra parameter named flag, but it's minimum API is 24.
对于较低的API版本,此功能是否可以替代?我不想为此使用WebView
.
Is there any alternative to this function to the lower API versions?. I don't want to use a WebView
for this purpose.
推荐答案
任一:
-
在所有API级别上使用
Html.fromHtml(String)
,或者
在API级别23和更旧的设备上使用Html.fromHtml(String)
,在API级别24+的设备上使用Html.fromHtml(String, int)
,并使用Build.VERSION.SDK_INT
找出您所运行的设备的API级别
Use Html.fromHtml(String)
on API Level 23 and older devices, and Html.fromHtml(String, int)
on API Level 24+ devices, using Build.VERSION.SDK_INT
to find out the API level of the device that you are running on
在这种情况下,不赞成使用"是寻找两参数方法的提示,但是单参数方法仍然有效,并且(很可能)将在相当长的一段时间内有效.
In this case, "deprecated" is a hint to go look for the two-parameter method, but the one-parameter method still works and (in all likelihood) will do so for quite some time.
这篇关于不推荐使用Html.fromHtml(),替代品是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!