I have implemented onSharedPreferenceChanged in my Preference
Activity, which works for other preference settings but it won't get
triggered when I click on the DialogPreference. I have also tried to
add set the OnPreferenceClickListener to the DialogPreference, which
also works, but this gets triggered as soon as I click on the
preference screen and not on one of the buttons in the actual dialog
window.
I would like to somehow implement the onClick method but don't know
where to do this.
public class Preferences extends PreferenceActivity implements
OnSharedPreferenceChangeListener {
private static final String LOG = "test";
private DialogPreference mfactory;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
mfactory = (DialogPreference)findPreference
("pref_factory");
mfactory.setOnPreferenceClickListener(new
DialogPreference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference)
{
Log.i(LOG, "onPreferenceClick1 entered");
// TODO Auto-generated method stub
return false;
}});
}
@Override
protected void onResume() {
super.onResume();
Log.i(LOG, "onResume entered");
// Add a Listener
getPreferenceScreen().getSharedPreferences
().registerOnSharedPreferenceChangeListener(this);
}
@Override
protected void onPause() {
super.onPause();
Log.i(LOG, "onPause entered");
// Remove the Listener
getPreferenceScreen().getSharedPreferences
().unregisterOnSharedPreferenceChangeListener(this);
}
public void onSharedPreferenceChanged(SharedPreferences
sharedPreferences, String key) {
Log.i(LOG, "onSharedPreferenceChanged entered");
}
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---