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. GLSurfaceview on top on a SurfaceView

Look at this:

They show that it is possible to put  an GLSurfaceview on top on a

I hope it would be useful.


2. SQlite Db problems

hai developers,

       i want to know  how to store the images in SQLite database in
android.and also how to retrieve  it.  anyone give the samplecode or
any URL give me to develop my application.


3. BitmapFactory.decodeStream sometimes returns null

4. service dies without calling onDestroy()

5. Building APPS that require an online database

6. Blank screen displayed after downloading from Android Browser.

7. Using intent with startActivity from inner class