如何使用 HtmlCompat?
How to use HtmlCompat?
我有以下代码:
Html.fromHtml(getString(R.string.privacy_policy_text)
然而,Html.fromHtml()
已被弃用。我知道我应该按照 here 的指示使用 HtmlCompat
。但是,我不知道我必须在 build.gradle 文件中包含什么才能使 class 即使经过大量谷歌搜索后仍然可用。
我的 build.gradle 中已有以下支持库:
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:recyclerview-v7:27.1.1'
在 Android JavaDocs 的当前版本中,有关于哪个工件提供特定 class 的注释。
在这里,我们看到“属于 Maven 工件 androidx.core:core:1.0.0-beta1”。这告诉您要使用的特定工件和版本,尽管您可能需要与其他版本同步您正在使用的工件。
这是一个 androidx
工件,作为支持库重大重构的一部分。这可能会导致您的项目出现问题,该项目正在使用 classic 支持库工件。您可能希望推迟使用 HtmlCompat
,直到您可以将整个项目切换到 androidx
个工件。
我有以下代码:
Html.fromHtml(getString(R.string.privacy_policy_text)
然而,Html.fromHtml()
已被弃用。我知道我应该按照 here 的指示使用 HtmlCompat
。但是,我不知道我必须在 build.gradle 文件中包含什么才能使 class 即使经过大量谷歌搜索后仍然可用。
我的 build.gradle 中已有以下支持库:
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:recyclerview-v7:27.1.1'
在 Android JavaDocs 的当前版本中,有关于哪个工件提供特定 class 的注释。
在这里,我们看到“属于 Maven 工件 androidx.core:core:1.0.0-beta1”。这告诉您要使用的特定工件和版本,尽管您可能需要与其他版本同步您正在使用的工件。
这是一个 androidx
工件,作为支持库重大重构的一部分。这可能会导致您的项目出现问题,该项目正在使用 classic 支持库工件。您可能希望推迟使用 HtmlCompat
,直到您可以将整个项目切换到 androidx
个工件。