first question. long time searcher.
i implemented a timePicker preference through expansion of DialogPreference as in the android docs. all works well and i can set the summary through onSharedPreferenceChanged() and also in the override of DialogPreference onSetInitialValue().
my goal is to always have the summary shown with its value and some other strings from resources.
for instance in my ListPreference i have:
android:summary="@string/pref_list_camera_summary"
which resolves to:
<string name="pref_list_camera_summary">Use camera: %s</string>
in my timePreference %s doesn't get expanded. i've searched around and i can't figure out how to get the dialogPreference/timePreference to do this. i can set the summary manually in onSetInitalValue() like this:
setSummary(getSummary() + " " + DateFormat.getTimeFormat(getContext()).format(new Date(calendar.getTimeInMillis())));
i just don't like implied expansion like that. doesn't feel as clean or use the android %s paradigm.
i'll start digging through the listPreference code and see how i can add this to dialogPreference. any ideas/head-starts would be great!
thanks!
getSummary()
is not called in the first place. If you can somehow tweak the derived preference class to make sure it gets called you could indeed use thestring.format()
trick. – Carloscarlota