16.02.2011 11:43, Mattias Svala ?????:


OK. I think that is the way to go too. I have made some attempts at implementing this but has so far not found a way to set the actual preference value when I get hold of the picked contact. Preference does not have a setValue method. How did you envision this to be done?

Storing the value is your preference's responsibility.

Typically, you have something like this in your preference:

    public void setValue(int value) {
        mValue = value;
        persistInt(value);
    }

Where mValue is a type-specific member of your class, and persistInt() is a helper method defined in Preference.

And how does setValue get called? It depends on the type of preference, for example, for a DialogPreference subclass:

    @Override
    protected void onDialogClosed(boolean positiveResult) {
        super.onDialogClosed(positiveResult);

        if (positiveResult) {
            if (callChangeListener(mNewValue)) {
                setValue(mNewValue);
            }
        }
    }

-- Kostya

--
Kostya Vasilyev -- http://kmansoft.wordpress.com

--
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