1
I would like to capture the user changed field in a class that inherits from Preferenceactivity.
I tried unsuccessfully to overwrite: onContentChanged() and onActivityResult.
1
I would like to capture the user changed field in a class that inherits from Preferenceactivity.
I tried unsuccessfully to overwrite: onContentChanged() and onActivityResult.
2
The class Preference
, as well as various elements of Android, have events.
In the case of the class Preference
, she has two winds: OnPreferenceChange
and OnPreferenceClick
. I believe the first is what you need.
To be notified of the change in value of a Preference
, you must register a OnPreferenceChangeListener
in the desired preference.
To use:
Preference p = findPreference("erp_cod_vendedor");
p.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) {
// Valor mudou, faca algo
return true; // Pode persistir o novo valor
}
});
Browser other questions tagged android
You are not signed in. Login or sign up in order to post.
Herik, you want to listen for the value exchange of a subclass of
Preference
(given its instance), or wants to listen for any change of value (for anyPreference
)? You want to do inside thePreferenceActivity
or outside?– Wakim
It would be inside my activity that inherits from Preferenceactivity, in this case I want to take a specific Preference. As defined in xml: <Edittextpreference android:key="erp_cod_seller"/>
– Herik R