Android TV首选项标准

时间:2015-04-03 12:02:19

标签: android android-5.0-lollipop android-tv

在查看Android TV偏好设置和内置应用程序(如YouTube)时,它们似乎使用标准布局,如下所示:

Preference Screen 1

Preference Screen 2

我找不到在Android TV上实现偏好的任何示例,也找不到任何LeanBack等库中引用的上述布局。

这是一个"标准"我可以重用(比如普通的Android PreferenceFragment),还是我必须设计自己的偏好系统?

可以使用LeanBack" BrowseFragment"复制第一张图片。但是使用我迄今发现的任何东西都无法实现较低的一个。

3 个答案:

答案 0 :(得分:4)

<强>更新

new support libraries刚刚发布。所有的冰雹GuidedStepFragment!它应该是你正在寻找的。


不,遗憾的是,该视图未作为Leanback库中的独立窗口小部件提供。如果你想看看自己,see here

它可以很容易地实现,但是,唉,你自己。

答案 1 :(得分:1)

Since the time period when the original was answered, there is now a Leanback preferences support library that can be included and used. See the following link: http://developer.android.com/tools/support-library/features.html#v17-preference

In particular you not only want the GuidedStepFragment, but also to extend the BaseLeanbackPreferenceFragment.

答案 2 :(得分:0)

我在Android STB的AOSP版本中找到了这段代码

适用于Android 6.0 AOSP以及原装Android TV。非电视设备需要对resolveActivity()进行额外检查。

public static String COMPONENT_TV_SETTINGS = "com.android.tv.settings/com.android.tv.settings.MainSettings";

Intent intent = new Intent();
intent.setComponent(ComponentName.unflattenFromString(COMPONENT_TV_SETTINGS));

if (intent.resolveActivity(getActivity().getPackageManager()) == null) {
    intent.setAction(Settings.ACTION_SETTINGS); // Standard settings
}

startActivity(intent);