Zul*_*Zul 8 android android-preferences
如何为Android本机设置应用程序进行SwitchReference的设置导航?
当你点击WiFi区域(不在交换机上)时,它将导航到一个新屏幕:

我的应用程序只将开关从ON更改为OFF,反之亦然,即使我没有点击开关.
我正在使用PreferenceFragment和xml的屏幕.我的偏好是遵循Android PreferenceFragment文档中的示例.我在ICS 4.0 API 14上开发我的应用程序.
有人知道怎么做吗?
编辑:
我的XML看起来像这样:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory
android:layout="@layout/preference_category"
android:title="User Settings" >
<SwitchPreference
android:key="pref_autorun"
android:layout="@layout/preference"
android:summary="Autorun SMODE on boot"
android:title="Autorun SMODE" />
<SwitchPreference
android:key="pref_wifi_control"
android:layout="@layout/preference"
android:selectable="false"
android:summary="Controls your Wi-Fi radio automatically based on hotspot availability"
android:title="Wi-Fi Radio Control" />
</PreferenceCategory>
</PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)
通过查看股票设置应用程序的来源,您可以找到他们是如何做到的.
基本上,他们使用自定义ArrayAdapter(就像使用ListView一样)来显示带有Switch按钮的行.对于第二个屏幕,他们只使用ActionBar中提供的CustomView.
我写了一篇带有示例代码的文章,以展示如何在项目中完成它.但请注意,这只能在API级别14或更高版本中推卸,因此如果您定位较旧的设备,请保留旧的样式首选项屏幕.
| 归档时间: |
|
| 查看次数: |
4405 次 |
| 最近记录: |