首选项和操作栏中的开/关切换按钮 - 冰淇淋三明治样式

aim*_*ngo 15 android togglebutton android-preferences android-4.0-ice-cream-sandwich android-actionbar

我指的是蓝色ON/OFF样式,如ICS手机上的默认Android设置应用程序所示.它也可以在这里看到:http://android-developers.blogspot.com/2012/02/android-design-v2-now-with-stencils.html 我想将它们放在Preference屏幕中,我是否必须使用自定义首选项小部件?

此外,在操作栏中放置切换按钮是否容易?这似乎是可能的,因为它是在ICS的默认Android设置中为Wifi设置完成的,但它可能是一个自定义菜单项?

任何帮助是极大的赞赏.

use*_*421 32

就像:
我的xml-v14/preferences.xml

<SwitchPreference
    android:key="@string/feature_id"
    android:title="@string/feature_title" />
Run Code Online (Sandbox Code Playgroud)

兼容性:
我的xml/preferences.xml

<CheckBoxPreference 
    android:key="@string/feature_id"
    android:title="@string/feature_title" />
Run Code Online (Sandbox Code Playgroud)