How do I implement the onClick method for a DialogPreference?

by Nick » Sat, 22 Aug 2009 01:53:28 GMT

Sponsored Links
 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

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;

        protected void onCreate(Bundle savedInstanceState) {

            // Load the preferences from an XML resource

            mfactory = (DialogPreference)findPreference
DialogPreference.OnPreferenceClickListener() {

                        public boolean onPreferenceClick(Preference preference) 
                                Log.i(LOG, "onPreferenceClick1 entered");

                                // TODO Auto-generated method stub
                                return false;

        protected void onResume() {
                Log.i(LOG, "onResume entered");

                // Add a Listener

        protected void onPause() {
                Log.i(LOG, "onPause entered");

                // Remove the Listener

        public void onSharedPreferenceChanged(SharedPreferences
sharedPreferences, String key) {
                Log.i(LOG, "onSharedPreferenceChanged entered");



Other Threads

1. HTC Magic/Cupcake - web connection hangs on local network

HTC Magic

I have a web server and the phone on the same WiFi network. I'm
testing a web app on the web server. The phone stopped connecting to
the server, and just hangs as if the connection is blocked.

Ping to the phone from the server is OK.

A reset of the WiFi interface resolves this.

Any idea, or having the same problem?


2. Doubts in Android Build System

I have included a simple application (HelloWorld application)
along with other System packages @ /packages/apps
This is not getting built completely. It does generate the
intermediate folder @ out/target/common/obj/APPS. This folder contains but the classes.jar and classes.dex are not getting generated.
Consequently .apk is not getting generated. Please let me know what
change i have to bring about to let the desired happen. I want this
HelloWorld application to be a part of the system image. I have also
included it in the manifest.xml. It does not help.
Please help.

Many Thanks,


3. How to get the event when the _current_ application install finished.

4. Is it possible to start activity when received a broadcast?

5. Upgrade to Android 1.6 on Google IO Device -- where did Amazon MP3 go?

6. Detecting screen size group (normal,large, small)

7. Google Goggles