安卓:使用开关preference pre API级别14 [英] Android: Using Switch Preference pre API level 14

查看:104
本文介绍了安卓:使用开关preference pre API级别14的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pre-API级别14没有开关preference。如果我使用preferences.xml创建我的preference屏幕上是有一些方法的API等级来区分?因此,有老版本的复选框,并切换为API 14?

什么是最好的方法是什么?

解决方案
  

如果我用preferences.xml创建我的preference屏幕上是有一些方法的API等级来区分?因此,有老版本的复选框,并切换为API 14?

创建一个 RES / XML-V14 / 目录,其中包含一个 preferences.xml 有你开关preference 。创建一个 RES / XML / 目录,其中包含一个 preferences.xml 文件替换开关preference 复选框preference 。 Android将基于应用程序上运行的设备版本加载正确的 preferences.xml 文件的版本。

Pre-API Level 14 there is no switch preference. If I use preferences.xml to create my preference screen is there some way to distinguish between the API levels? So having a check box for old releases and a switch for API 14?

What would be the best way?

解决方案

If I use preferences.xml to create my preference screen is there some way to distinguish between the API levels? So having a check box for old releases and a switch for API 14?

Create a res/xml-v14/ directory that contains a preferences.xml that has your SwitchPreference. Create a res/xml/ directory that contains a preferences.xml file that replaces the SwitchPreference with a CheckBoxPreference. Android will load the right preferences.xml file edition based on the device version the app is running on.

这篇关于安卓:使用开关preference pre API级别14的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆