0

For configuring a row of a database table, I'd like to use a UI identical to the Android Preference classes UI. For example, this would be setting a bunch of checkboxes / radios / etc to configure an alarm, in a table that held a number of user-created alarms.

Is it possible and/or appropriate to use the Preference classes for this, rather than manually building my own forms to mimic the UI? I want the UI to look as 'standard' as possible across the range of Android versions.

pancake
  • 3,232
  • 3
  • 22
  • 35

1 Answers1

1

Pass the row id from the previous activity and set OnPreferenceChangeListener for each preference, and and every time Preference changes you can update the row.

You could also pass back all values from the preferenceActivity to the calling activity through setResult and update row in OnActivityResult

nandeesh
  • 24,740
  • 6
  • 69
  • 79
  • Thanks nandeesh - if I understand you're suggesting I'd have a single set of Preferences that would temporarily be over-written to represent the current database row. Before displaying the Preferences, I could set their values to the current table row by accessing SharedPreferences.Editor. This seems like a bit of a hack, using Preferences for something they're not designed to do. Really what I want to do is use the UI of the Preference classes without their built-in back-end logic. Maybe there is no nice way to do this? – pancake Aug 27 '12 at 07:12
  • Its kind of a hack, but many apps in the Android source use such approach. So it is a common approach – nandeesh Aug 27 '12 at 08:13
  • Ok that helps - if it's good enough for the Android source, it's good enough for me! Thanks – pancake Aug 27 '12 at 22:09