I’ve got an Android preference activity where the layout is connected directly to my peference key/value pairs, ex:
<EditTextPreference
android:key="timeout"
android:defaultValue="timeout"
android:title="Timeout"
android:summary="Timeout (ms)"
android:dialogTitle="Timeout (ms)" />
I need to change this somehow so that the display function (and only the display) is in seconds. Theoretically I could change it so that the storage and retrivial of the value use seconds, but that happens far too often, so I dont want to change that if I can avoid it.
The activities/services that make up my app all pull directly from the Android preferences, ex:
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(ctx);
String s = settings.getString("timeout", ctx.getString(R.string.timeout));
So – what’s the best way to change the display function for the preference, while still storing the values in milliseconds?
I think, android is saving the value of a
EditTextPreferenceusing thesetText()method. So you could use a custom View extendingEditTextPreferenceand modifysetText().