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. Find tools on windows

In android sdk for windows, cant find tools like dexdump.exe,
dexlist.exe and dexopt.exe.

Can any one provide these tools for me?

2. How to kill an ImageView?... thx

Hey All,

I'm trying to transition from my main splash screen to the next part
of my code.  How do I kill my splash screen?...  In my main.xml the
splash screen image is simply:


directly under the <Imageview in my main.xml file I have <TextViews
and <Spinners.  Does the <Imageview portion of my text need to reside
in a different .xml file?...

The Dev Guide suggests using an expand_collapse.xml, which is fine,
but I'm not sure where to place the bottom part of that tutorial

<With this XML saved in the file res/drawable/expand_collapse.xml, the
following code will instantiate the TransitionDrawable and set it as
the content of an ImageView:

Resources res = mContext.getResources();TransitionDrawable transition
= (TransitionDrawable) res.getDrawable
(R.drawable.expand_collapse);ImageView image = (ImageView) findViewById

Is this a seperate .java file?  How do these pieces fit together?

Thx in advance!


3. Seek the leb128's beb128 counterpart

4. Getting cell signal strength for current cell vs neighboring cells

5. For those following the AndAppStore / Archos dispute.

6. multi resolution image button selectors broken?

7. Sending market link in mail