Skip to content Skip to sidebar Skip to footer

Howto Make A Layout Similar To The Ones In Settings

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 th

Solution 1:

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.

Solution 2:

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.

Post a Comment for "Howto Make A Layout Similar To The Ones In Settings"