draf...@gmail.com wrote:
> I was wondering can anyone direct me to a detailed Preferences
> tutorial?
> 
> Or provide me with a bit of help here?
> 
> I have my preferences saved in preferences.xml as follows:
> 
> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/
> android">
> <PreferenceCategory android:title="Wifi Settings">
> 
>     <EditTextPreference
>             android:key="edittext_block_attach_err"
>             android:title="@string/title_edittext_preference"
>             android:summary="@string/summary_edittext_preference"
>             android:dialogTitle="@string/
> dialog_title_edittext_preference" />
> 
> </PreferenceCategory>
> 
> </PreferenceScreen>
> 
> I then have a preference activity as follows:
> 
> public class WlanSettings extends PreferenceActivity {
> 
> SharedPreferences prefs;
> 
> 
> @Override
> protected void onCreate(Bundle savedInstanceState) {
>     super.onCreate(savedInstanceState);
> 
>     addPreferencesFromResource(R.xml.preferences);
>     prefs = this.getSharedPreferences("CiceroWlanSettings",
> Activity.MODE_PRIVATE);
> 
> 
> }
> 
> This display's the EditTextPreference fine but how do I then set up a
> default preference to be displayed in the dialog box that pops up with
> an EditTextPreference?

android:defaultValue in the XML.

> And How do I save changes that occur in my preference activity to my
> preferences?

It happens automatically.

I don't know what that prefs=this.getSharedPreferences() line is for.
It's not needed, and it's probably reading the wrong file, anyway. Use
PreferenceManager.getDefaultSharedPreferences() for work with the file
that will be used by the PreferenceActivity.

See:

http://github.com/commonsguy/cw-android/tree/master/Prefs/Dialogs/

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 2.0 Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to