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.
You could also use the android-switch-backport library which has a SwitchPreference which works on Android 2.1+.
https://github.com/BoD/android-switch-backport
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With