Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compatibility for SwitchPreference (pre ICS)?

Is the SwitchPreference introduced in ICS compatible in the android-support-v4 library? I'm trying to update some old projects and would like to use SwitchPreferences if possible.

I know I can make a separate resource file to distinguish the API version, but I'd like to avoid that if at all possible.

like image 223
SD_Guru Avatar asked May 21 '12 20:05

SD_Guru


1 Answers

Is the SwitchPreference introduced in ICS compatible in the android-support-v4 library?

No, sorry.

However, it shouldn't be too tricky to backport it, if someone hasn't already.

Actually, it may be a bit of a pain, since it also requires a backport of Switch, and backporting widgets is sometimes troublesome because they frequently use package-private methods that backports cannot access.

I know I can make a separate resource file to distinguish the API version, but I'd like to avoid that if at all possible.

Well, that would certainly be way simpler than the alternatives:

  • the aforementioned backport

  • creating some sort of alias Preference mechanism that allows you to use SwitchPreference on newer devices and CheckBoxPreference on older devices with only one resource file

like image 80
CommonsWare Avatar answered Sep 23 '22 18:09

CommonsWare