Android: Using Switch Preference pre API level 14

后端 未结 5 1657
有刺的猬
有刺的猬 2020-12-13 19:04

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

5条回答
  •  心在旅途
    2020-12-13 19:50

    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.

提交回复
热议问题