I've set up a Preference Screen as a settings option in my App, but I am totally confused about how to make the changes done when user selects or changes an Option.
Here's the xml code of my PreferenceScreen:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="Notifications">
<RingtonePreference
android:summary="Choose a Ringtone"
android:title="Notification Ringtone"
android:key="ringtonePref" />
<ListPreference
android:title="Notification Timer"
android:summary="Select when to Notify"
android:dialogTitle="Show Notification after every:"
android:positiveButtonText="OK"
android:negativeButtonText="Cancel"
android:entries="@array/entries"
android:entryValues="@array/entries"
android:key="listPrefs" />
<ListPreference
android:title="LED Color"
android:summary="Choose LED Color"
android:positiveButtonText="OK"
android:negativeButtonText="Cancel"
android:entries="@array/colors"
android:entryValues="@array/colors"
android:key="listPrefs2" />
<CheckBoxPreference
android:title="LED"
android:defaultValue="true"
android:summary="Flash LED or Not"
android:key="checkBoxPrefs2"/>
<CheckBoxPreference
android:title="Vibrate"
android:defaultValue="true"
android:summary="Vibrate on receiving Notification"
android:key="checkBoxPrefs3" />
</PreferenceCategory>
<PreferenceCategory android:title="Invite">
<Preference android:summary="Send invitation to more peoples so that\nthey can also Learn more and more Duas."/>
</PreferenceCategory>
<PreferenceCategory android:title="Version">
<Preference
android:key="versionPrefs"
android:summary="Version 1.0\nThank you for Downloading the App." />
</PreferenceCategory>
</PreferenceScreen>
and here is my Settings.class:
public class Settings extends PreferenceActivity implements OnPreferenceChangeListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
//setting the properties of Action Bar
ActionBar actionBar = getActionBar();
actionBar.setTitle(Html.fromHtml("<font color='#FFFFFF'><strong>Settings</strong></font>"));
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#33B5E5")));
actionBar.setDisplayHomeAsUpEnabled(true);
PreferenceManager.setDefaultValues(this, R.xml.settings, true);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// TODO Auto-generated method stub
return false;
}
}
I don't know what code should I add to onPreferenceChange to make my Preferences actually do the change.
Please tell me.
Any help would be highly Appreciated.
Thanks for your precious time.