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.