4

My desired custom preference looks very much like the out-of-box EditTextPreference, only that it behaves like a "split button" which combines two Preferences: if user clicks on the text on the left, the edit text dialog pops up; which allows user to set the "label" for the preference; if user clicks on the button on the right, another window pops up that allows user to set the "date" for the preference.

I guess I could extend EditTextPreference but I am not sure how I can maintain two separate keys for a single preference control (or "widget" in Android's term). Or is it possible to "mix up" two Preferences without subclassing?

mobileTofu
  • 1,071
  • 2
  • 14
  • 25
  • Looks like I need something like a PreferenceGroupAdapter (http://www.androidjavadoc.com/1.1_r1_src/android/preference/PreferenceGroupAdapter.html)? But strangely this class is private. – mobileTofu Oct 02 '11 at 03:33

1 Answers1

0

Really you do not have to use the built in preference widgets to manage your preferences; for example, in my application, i use a PreferenceScreen to bring up a multiple selection dialog with a custom listview/adapter. If you wish to handle your own key/value store, you could bind to the preference with findPreference(), set the value in the PreferenceActivity's onCreate() and persist the value in the activity's onPause(). Examining the key / value preference store can be done via getSharedPreferences(file,MODE.PRIVATE) and an associated getter method. To edit them, take the SharedPreferences object that's returned and call edit() / commit() on it once changes have been made.

Does this answer you question?

Blaskovicz
  • 6,122
  • 7
  • 41
  • 50