Hello everyone,

I am currently trying to implement a PreferenceActivity for my
application that uses custom default values for its preferences
instead of the defaults declared in the corresponding preference XML
as the defaults are supposed to change dynamically based on certain
conditions.

However, when I modify the defaults via the Android API after loading
the preferences through
  addPreferencesFromResource(R.xml.preferences);
it already seems to be too late and the individual defaults set via
Preference.setDefaultValue do not seem to be taken into consideration
when rendering the UI.

The cause seems to be that the defaults are read immediately (if
necessary) in the Preference.onAttachedToHierarchy callback, which is
triggered synchronously within the addPreferencesFromResource call
(via PreferenceManager.inflateFromResource).

As I would like to avoid re-inventing the wheel I hope there is some
possibility to achieve this using the standard Android preference API.
Is there any way to trigger a re-evaluation of the values (and default
values) associated with a PreferenceScreen hierarchy?

I did not yet try whether creating the PreferenceScreen via APIs
instead of loading from XML would help, so that could be an option.

Thanks,
Thilo

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to