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.

I think I need to implement onClick for this dialog but I am not sure
where to do this.  I have looked at the API Demo code and it shows how
to create the dialog but not how to determine which button was
pressed.

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
(SharedPreferencessharedPreferences, String key) {
                Log.i(LOG, "onSharedPreferenceChanged entered");
                    if (key.contains("seekbar")) {
                    }
                }
        }
}

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