I would like to capture the user-modified field in a class that inherits from PreferenceActivity.
I tried unsuccessfully to override: onContentChanged () and onActivityResult.
I would like to capture the user-modified field in a class that inherits from PreferenceActivity.
I tried unsuccessfully to override: onContentChanged () and onActivityResult.
The Preference
class, as well as various Android elements, have events.
In the case of class Preference
, it has two winds: OnPreferenceChange
and OnPreferenceClick
. I think the first one is what you need.
To be notified of the change of 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
}
});