android - 实现 SeekBarPreference

标签 android sharedpreferences android-8.0-oreo seekbarpreference

我在类中实现 SeekBarPreference 时遇到问题。

https://developer.android.com/reference/android/support/v7/preference/SeekBarPreference.html

如您所见,此 SeekBarPreference 在 25.1.0 中可用,我在 xml 中实现了它,UI 看起来不错。我需要在默认共享首选项中保存此搜索栏的值。这就是我遇到的问题,android.support.v7.preference.SeekBarPreference 没有导入选项。现在不用了吗?

我将我的应用程序更新为 26.0.1 并尝试手动添加导入,但它没有设置。有什么建议吗?

最佳答案

您需要在依赖项中包含 preference-v7 库

compile 'com.android.support:preference-v7:26.0.0'

然后你就可以导入这个类了

import android.support.v7.preference.SeekBarPreference;

如果您使用 26 版 sdk 进行编译,则支持库版本应为 26.0.0,目前为 latest version . 26.0.1 好像不存在

关于android - 实现 SeekBarPreference,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45433928/

相关文章:

android - 使用隐式 Intent 时如何在我的代码中解析 A​​ctivityNotFoundException?

android - 为什么我的首选项的默认值没有保存到 SharedPreferences?

java - 使用共享首选项在单击按钮时保存字符串

android - 首次展示的Activity解决方案

android - 将 Lottie Android 与矢量图像 (xml) 或 svg 图像一起使用?

android - 自动升级系统apk为setting.apk

android - imageview 设置选择器文件以编程方式使用无效。 (安卓)

Android O 通知不显示

Android 26 (O) 通知不显示操作图标

Android "O"(Oreo, 8) 和更高版本的媒体按钮问题