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 DialogPreference
s 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
.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.