Add SwitchPreference demo in ApiDemos.
Renamed toggle to Checkbox. Update to trigger build queue recompilation. Change-Id: Ie7800b5e41e86f8182bb550da869ccb316cbeb91
This commit is contained in:
committed by
Gilles Debunne
parent
d318f21b4b
commit
c81d080a6a
@@ -518,12 +518,13 @@
|
||||
<string name="launch_preferences">Launch preferences</string>
|
||||
<string name="preference_attributes">Preference attributes</string>
|
||||
|
||||
<string name="title_toggle_preference">Toggle preference</string>
|
||||
<string name="summary_toggle_preference">This is a toggle button</string>
|
||||
|
||||
<string name="title_checkbox_preference">Checkbox preference</string>
|
||||
<string name="summary_checkbox_preference">This is a checkbox</string>
|
||||
|
||||
<string name="title_switch_preference">Switch preference</string>
|
||||
<string name="summary_switch_preference">This is a switch</string>
|
||||
<string name="summary_switch_preference_yes_no">This is a switch with custom text</string>
|
||||
|
||||
<string name="title_yesno_preference">Yes or no preference</string>
|
||||
<string name="summary_yesno_preference">An example that uses a yes/no dialog</string>
|
||||
<string name="dialog_title_yesno_preference">Do you like bananas?</string>
|
||||
@@ -555,9 +556,9 @@
|
||||
<string name="summary_on_advanced_toggle_preference">I\'m on! :)</string>
|
||||
<string name="summary_off_advanced_toggle_preference">I\'m off! :(</string>
|
||||
|
||||
<string name="title_parent_preference">Parent toggle</string>
|
||||
<string name="title_parent_preference">Parent checkbox preference</string>
|
||||
<string name="summary_parent_preference">This is visually a parent</string>
|
||||
<string name="title_child_preference">Child toggle</string>
|
||||
<string name="title_child_preference">Child checkbox preference</string>
|
||||
<string name="summary_child_preference">This is visually a child</string>
|
||||
|
||||
<string name="example_preference_dependency">Example preference dependency</string>
|
||||
|
||||
@@ -20,11 +20,17 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="default_toggle"
|
||||
android:key="default_checkbox"
|
||||
android:defaultValue="true"
|
||||
android:title="@string/title_checkbox_preference"
|
||||
android:summary="@string/summary_checkbox_preference" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="default_switch"
|
||||
android:defaultValue="false"
|
||||
android:title="@string/title_switch_preference"
|
||||
android:summary="@string/summary_switch_preference" />
|
||||
|
||||
<EditTextPreference
|
||||
android:key="default_edittext"
|
||||
android:defaultValue="@string/default_value_edittext_preference"
|
||||
|
||||
@@ -24,8 +24,13 @@
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="checkbox_preference"
|
||||
android:title="@string/title_toggle_preference"
|
||||
android:summary="@string/summary_toggle_preference" />
|
||||
android:title="@string/title_checkbox_preference"
|
||||
android:summary="@string/summary_checkbox_preference" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="checkbox_preference"
|
||||
android:title="@string/title_switch_preference"
|
||||
android:summary="@string/summary_switch_preference" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
@@ -24,8 +24,20 @@
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="checkbox_preference"
|
||||
android:title="@string/title_toggle_preference"
|
||||
android:summary="@string/summary_toggle_preference" />
|
||||
android:title="@string/title_checkbox_preference"
|
||||
android:summary="@string/summary_checkbox_preference" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="checkbox_preference"
|
||||
android:title="@string/title_switch_preference"
|
||||
android:summary="@string/summary_switch_preference" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="checkbox_preference"
|
||||
android:title="@string/title_switch_preference"
|
||||
android:summary="@string/summary_switch_preference_yes_no"
|
||||
android:switchTextOn = "YES"
|
||||
android:switchTextOff = "NO" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.example.android.apis.preference;
|
||||
|
||||
import com.example.android.apis.R;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.res.TypedArray;
|
||||
import android.net.Uri;
|
||||
@@ -26,8 +28,7 @@ import android.preference.ListPreference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceScreen;
|
||||
|
||||
import com.example.android.apis.R;
|
||||
import android.preference.SwitchPreference;
|
||||
|
||||
public class PreferencesFromCode extends PreferenceActivity {
|
||||
|
||||
@@ -47,12 +48,19 @@ public class PreferencesFromCode extends PreferenceActivity {
|
||||
inlinePrefCat.setTitle(R.string.inline_preferences);
|
||||
root.addPreference(inlinePrefCat);
|
||||
|
||||
// Toggle preference
|
||||
CheckBoxPreference togglePref = new CheckBoxPreference(this);
|
||||
togglePref.setKey("toggle_preference");
|
||||
togglePref.setTitle(R.string.title_toggle_preference);
|
||||
togglePref.setSummary(R.string.summary_toggle_preference);
|
||||
inlinePrefCat.addPreference(togglePref);
|
||||
// Checkbox preference
|
||||
CheckBoxPreference checkboxPref = new CheckBoxPreference(this);
|
||||
checkboxPref.setKey("checkbox_preference");
|
||||
checkboxPref.setTitle(R.string.title_checkbox_preference);
|
||||
checkboxPref.setSummary(R.string.summary_checkbox_preference);
|
||||
inlinePrefCat.addPreference(checkboxPref);
|
||||
|
||||
// Switch preference
|
||||
SwitchPreference switchPref = new SwitchPreference(this);
|
||||
switchPref.setKey("switch_preference");
|
||||
switchPref.setTitle(R.string.title_switch_preference);
|
||||
switchPref.setSummary(R.string.summary_switch_preference);
|
||||
inlinePrefCat.addPreference(switchPref);
|
||||
|
||||
// Dialog based preferences
|
||||
PreferenceCategory dialogBasedPrefCat = new PreferenceCategory(this);
|
||||
|
||||
Reference in New Issue
Block a user