Custom dialog in PreferenceActivity loaded from addPreferencesFromResource()?

by Chander Pechetty » Thu, 05 Feb 2009 18:57:08 GMT


Sponsored Links
 <DialogPreference
            android:key="yourdialogkey"
.....
...</DialogPreference>

In your PreferenceActivity class, just call
 Preference dialogPref = findPreference(yourdialogkey);

Get the dialog Layout if you are using a custom View or call one of
the SetMessage methods.
--~--~---------~--~----~------------~-------~--~----~



Custom dialog in PreferenceActivity loaded from addPreferencesFromResource()?

by g1bb » Thu, 05 Feb 2009 22:23:26 GMT


 Gotcha. I'm trying to do this in onSharedPreferenceChanged(), but I
can't seem to get it to hit.

public class Settings extends PreferenceActivity implements
OnSharedPreferenceChangeListener  {
        public static final String PREFS_NAME = "com.myapp.app_preferences";

        @Override
        public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
                settings = getSharedPreferences(PREFS_NAME, 0);

                addPreferencesFromResource(R.layout.settings);

        }

        public void onSharedPreferenceChanged(SharedPreferences
sharedPreferences, String key) {
                Log.v("changed", key);
        }

Why am I not seeing this hit when I change the preference?

Thanks again!



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Custom dialog in PreferenceActivity loaded from addPreferencesFromResource()?

by g1bb » Wed, 11 Feb 2009 08:53:29 GMT


 Anyone have any ideas on this?

Thanks again!




--~--~---------~--~----~------------~-------~--~----~



Custom dialog in PreferenceActivity loaded from addPreferencesFromResource()?

by Chander Pechetty » Wed, 11 Feb 2009 15:01:09 GMT


 addPreferencesFromResource(R.layout.settings);
settings = getSharedPreferences(PREFS_NAME, 0);
settings.registerOnSharedPreferenceChangeListener(this);


Be sure to unregister it on onPause()



--~--~---------~--~----~------------~-------~--~----~



Custom dialog in PreferenceActivity loaded from addPreferencesFromResource()?

by g1bb » Thu, 12 Feb 2009 00:03:11 GMT


 Doh! I knew it was something simple I was forgetting.

Thanks!



--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Dell Mini 3 emulator skin now available for Android 2.0 SDK

Dell Mini 3 emulator skin now available for Android 2.0 SDK
http://teavuihuang.com/android

The Dell Mini 3, a keyboardless touch-screen Android phone was
launched on 13th November 2009. It will initially be available only
from China Mobile and Brazil's Claro. This emulator skin brings the
Dell Mini 3 to your Android 2.0 SDK in WVGA854 resolution (480x854
high density, normal screen). The emulator skin package, screenshots
and installation instructions are now available at the above website.

Tea Vui Huang's Android Page
[The No.1 website for Google Android Emulator Skins]

-- 

2. Links in WebView & context menu?

*bump*





-- 

3. Problem transitioning to TabActivity

4. Android on LG KM900 ARENA

5. Barcode

6. File passed to sever os of size zero

7. Person using Sprint Hero can't see application?