Deepzz
Deepzz

Reputation: 4571

Can't add Preference in ICS

How to add Preference in ICS using addPreferencesFromResource()? It is shown deprecated in ics. i've added a preference layout in xml folder.. but this could not be added to the Preference activity..

Upvotes: 1

Views: 1076

Answers (1)

AdamK
AdamK

Reputation: 21399

From HC/ICS onward you should use PreferenceFragment.addPreferencesFromResource() instead of Activity.addPreferencesFromResource(). However, this does require you switch how your preference code is structured - moving from an old style PreferenceActivity which directly adds the preferences to a new style PreferenceActivity that loads PreferenceFragments that then load the preferences. For an example of the new way, see the code sample in the PreferenceActivity docs.

Note that the support library does not PreferenceFragment for backward compatibility pre-HC.

Upvotes: 2

Related Questions