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. How to add a Fixed header in ListActivity - List4.java

Hi

I am not able to add a Fixed Header in  a customView / ListActivity
very similar to

sample - 
http://developer.android.com/guide/samples/ApiDemos/src/com/example/android/apis/view/List4.html


Thanks in advance

--JP

-- 

2. detect if there is a connection to internet

Hello,

I want to detect if there is a connection to Internet before launching a
webview.
How can I detect it?

-- 
Mrton

-- 

3. Cannot download SDK with eclipse 3.5 in ubuntu 9.10.

4. Is there any way to get Google to sign your app?

5. Signing application

6. DCHP Options in Android 2.0

7. drawing a circle using OpenGL ES