Reputation: 332
I have an android Activity where I need to have the user enter some information. The data lends itself to something like a PreferenceView with ListPreferance elements. I am sure that I could use the preferences interfaces to get what I need, but it would by cludgy. Is there a way to get these same widgets in a regular view?
Upvotes: 0
Views: 1090
Reputation: 30168
I recently solved this same issue by following a similar approach to the one listed here. It boils down to providing a preference XML to your PreferenceActivity and then backing it with your own Model, instead of the default sharedPreferences. In the example he uses a database but if you don't have a backing database (or you don't want to commit whenever a setting is changed) you can use a Map for backing the Editor.
Upvotes: 1
Reputation: 64700
You want to look at http://developer.android.com/reference/android/R.layout.html: this has all the layouts that are publicly available.
If you're in the mood to dig into the platform bits, look in your <ANDROID SDK FOLDER>/platforms/<platform number>/data/res/layout
for the preference*.xml files. This actually has all the individual widgets. You'd have a messy time digging under the hood to figure out which Views to bind callbacks to and to fetch values from, but you could assemble an Activity that looks astonishingly like a PreferencesView but uses whatever source data you choose.
Upvotes: 0