pats
pats

Reputation: 1291

Custom preference UI without preference activity android

This question has been asked may times, but still no convincing answer. I have just one activity which loads different fragments, so don't want to create a preference activity to replace this one activity. Is it possible to create my own UI and save preferences within a fragment without using preference activity?

Upvotes: 0

Views: 378

Answers (1)

maciekjanusz
maciekjanusz

Reputation: 4775

Absolutely, PreferenceActivity is just a convenience to automate working with shared prefs changed by user actions. There is nothing stopping you from, let's say, creating a check box element and obtaining a SharedPreferences object using your current context, and editing some prefs.

Also, if you have one activity just switching between fragments, you can also take advantage of a PreferenceFragment

Upvotes: 2

Related Questions