android - 如何正确导入 AndroidX,以便可以在 XML 中使用自动完成功能?
问题描述
我尝试使用此首选项布局
<PreferenceScreen
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
app:key="display"
app:title="Display">
<SwitchPreferenceCompat
app:key="notifications"
app:title="Enable message notifications"/>
</PreferenceCategory>
<Preference
app:key="feedback"
app:title="Send feedback"
app:summary="Report technical issues or suggest new features"/>
</PreferenceScreen>
但是关闭的 PreferenceCategory 和 PreferenceScreen 在编辑器中被删除,它说 android.pref... 已弃用!
当我用 androidx 指定完整路径时......错误消失了,但我想使用它们而不必指定完整路径......
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.preference:preference:1.1.0-rc01'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
更新:删除 .idea 文件夹并执行“无效缓存并重新启动”并没有解决它...
解决方案
推荐阅读
- wcf - 尝试使用 tcp 从托管 wcf 的服务器机器上的虚拟机上的客户端机器获取数据时出现错误 onwindows 服务
- jquery - Jquery 无法处理多次使用的 Vue 组件
- kubernetes - 无法使用 Minikube 在 Kubernetes 集群上本地运行 Mattermost
- javascript - 如何将函数调用添加到任务队列中?
- c++ - 将 C++ 模板参数转换为结构中的字符串
- powershell - 如何在 Windows 上将图像传递给 vagrant
- flutter - 在函数返回值之前等待流完成
- javascript - 这是一个有效的插入排序算法吗?还是冒泡排序?我很困惑
- sorting - 如果存在,按元在 woocommerce 类别中创建自定义产品排序选项
- abap - 两个选择循环成一个选择?