Grishka
Grishka

Reputation: 2595

PreferenceFragment on pre-ICS

How do I use PreferenceFragment on older Android versions? ActionBarSherlock and Google's compatibility library doesn't seem to have an alternative implementation. Will it work correctly if I make an ActivityGroup and add a PreferenceActivity into it as a simple fragment? Targeting only ICS and newer would solve all problems, but, unfortunately, 2.3.x does have a half of whole market.

Upvotes: 2

Views: 1057

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006584

How do I use PreferenceFragment on older Android versions?

You don't. As you note, there is no backport, and backporting it would be rather challenging (as I researched this once upon a time and ran away screaming).

Will it work correctly if I make an ActivityGroup and add a PreferenceActivity into it as a simple fragment?

I wouldn't do that. I would create a PreferenceActivity that uses PreferenceFragment on newer devices and just uses ordinary preference XML on older devices. Here is a sample project that demonstrates this.

Upvotes: 2

Related Questions