I have a DialogPreference in my Preference Activity and would like to
know which button was pressed. I have implemented the
OnSharedPreferenceChangeListener which does not seem to get triggered
when the DialogPreference is selected. I have also tried
OnPreferenceClickListener but this gets triggered as soon as the
DialogPreference is clicked from the main screen and not when one of
the actual dialog buttons was pressed. was.
So I think I need to implement onClick for this dialog but I am not
sure 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");
if (key.contains("seekbar")) {
}
}
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---