I have an activity which is used for editing some object. Currently its layout as a simple form but I’d like it to be more similar to preferences activity. I’d like to use the same layouts which are available there (e.g. CheckBoxPreference) but save changes to my object rather than to preferences. Is there an easy way to have an activity which looks like preferences but doesn’t use preferences at the back back-end?
Share
You can achieve this using next 2 steps:
Set preference to be not persistent via
android:persistent="false"in xml or viasetPersistent(false)in code. This way defaultSharedPreferenceswill not be modified when user changes values in preference UI.Handle value changes via
OnPreferenceChangeListenerlistener registered usingsetOnPreferenceClickListener. This will allow you to intercept changes and handle them the way you need.