API 29已弃用PreferenceScreen [英] PreferenceScreen has been deprecated by API 29

查看:606
本文介绍了API 29已弃用PreferenceScreen的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确实创建了首选项XML,然后看到API 29已弃用了 PreferenceScreen .替代什么?

您可以在此处看到折旧消息:

解决方案

基于 Google文档,并且根据Google的建议,您应该使用链接

如果迁移到Androidx 后仍然存在问题,则可以使用

 < androidx.preference.PreferenceScreenxmlns:android ="http://schemas.android.com/apk/res/android"></androidx.preference.PreferenceScreen> 

代替

 < PreferenceScreenxmlns:app =" http://schemas.android.com/apk/res-auto></PreferenceScreen> 

这不是必需的,但您也可以将此实现添加到Gradle中.

 实现'androidx.preference:preference:X.Y.Z' 

I did create preferences XML then I see the PreferenceScreen has been deprecated by API 29. What is the replacement?

And you can see depreciation message here:

解决方案

It's deprecated in API level 29 base on Google Document and also by the Google recommendation you should use AndroidX Preference Library instead.

You can check AndroidX Preference guide in this link

If you still have the problem after Migrate to Androidx you can use

<androidx.preference.PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android">

</androidx.preference.PreferenceScreen>

instead of

<PreferenceScreen
    xmlns:app="http://schemas.android.com/apk/res-auto">


</PreferenceScreen>

It's not necessary but you can add this implementation into your Gradle too.

implementation 'androidx.preference:preference:X.Y.Z'

这篇关于API 29已弃用PreferenceScreen的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆