whatyouhide
whatyouhide

Reputation: 16781

Adding custom setting to PreferenceFragment

I have a PreferenceFragment and I need to put custom preferences in it. Now the problems are not the custom preferences themselves, I already extended some DialogPreferences creating my own preferences and I already dealt with saving/restoring data; the problem is how do I add these custom preferences to my PreferenceFragment? I can't declare them in XML (can I?), and I can't find any method to dynamically add them to my PreferenceFragment.

Upvotes: 0

Views: 187

Answers (1)

A--C
A--C

Reputation: 36449

Haven't tried it myself, but for an xml based approach, maybe you can do this:

<com.mypackage.MyPreference
        android:defaultValue="value"
        android:key="key"
        android:title="Title"/>

Then use addPreferencesFromResource() as usual.

Upvotes: 2

Related Questions