Add new sample for multi-pane PreferenceActivity.
Also re-arrange all preference API demos to go in their own package, since the preferfence APIs themselves are in their own package. Change-Id: I305f77dc09748bb60d1de8a23d063db64c11bb1e
This commit is contained in:
@@ -48,7 +48,7 @@
|
|||||||
to be installed if it doesn't exist. -->
|
to be installed if it doesn't exist. -->
|
||||||
<uses-library android:name="com.example.will.never.exist" android:required="false" />
|
<uses-library android:name="com.example.will.never.exist" android:required="false" />
|
||||||
|
|
||||||
<activity android:name="ApiDemos">
|
<activity android:name="ApiDemos" android:screenOrientation="landscape">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
@@ -277,14 +277,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".app.FragmentPreferences"
|
|
||||||
android:label="@string/fragment_preferences">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name=".app.FragmentRetainInstance"
|
<activity android:name=".app.FragmentRetainInstance"
|
||||||
android:label="@string/fragment_retain_instance">
|
android:label="@string/fragment_retain_instance">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@@ -617,50 +609,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- Preferences Samples -->
|
|
||||||
|
|
||||||
<activity android:name=".app.PreferencesFromXml" android:label="@string/preferences_from_xml">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name=".app.PreferencesFromCode" android:label="@string/preferences_from_code">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name=".app.AdvancedPreferences" android:label="@string/advanced_preferences">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name=".app.LaunchingPreferences" android:label="@string/launching_preferences">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name=".app.PreferenceDependencies" android:label="@string/preference_dependencies">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name=".app.DefaultValues" android:label="@string/default_values">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<!-- Device Admin Samples -->
|
<!-- Device Admin Samples -->
|
||||||
|
|
||||||
<activity android:name=".app.DeviceAdminSample$Controller"
|
<activity android:name=".app.DeviceAdminSample$Controller"
|
||||||
@@ -702,6 +650,73 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<!-- ************************************* -->
|
||||||
|
<!-- PREFERENCE PACKAGE SAMPLES -->
|
||||||
|
<!-- ************************************* -->
|
||||||
|
|
||||||
|
<activity android:name=".preference.FragmentPreferences"
|
||||||
|
android:label="@string/fragment_preferences">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".preference.PreferenceWithHeaders"
|
||||||
|
android:label="@string/preference_with_headers">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".preference.PreferencesFromXml"
|
||||||
|
android:label="@string/preferences_from_xml">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".preference.PreferencesFromCode"
|
||||||
|
android:label="@string/preferences_from_code">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".preference.AdvancedPreferences"
|
||||||
|
android:label="@string/advanced_preferences">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".preference.LaunchingPreferences"
|
||||||
|
android:label="@string/launching_preferences">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".preference.PreferenceDependencies"
|
||||||
|
android:label="@string/preference_dependencies">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name=".preference.DefaultValues" android:label="@string/default_values">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<!-- ************************************* -->
|
<!-- ************************************* -->
|
||||||
<!-- CONTENT PACKAGE SAMPLES -->
|
<!-- CONTENT PACKAGE SAMPLES -->
|
||||||
<!-- ************************************* -->
|
<!-- ************************************* -->
|
||||||
|
|||||||
BIN
samples/ApiDemos/res/drawable-mdpi/ic_settings_applications.png
Executable file
BIN
samples/ApiDemos/res/drawable-mdpi/ic_settings_applications.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
BIN
samples/ApiDemos/res/drawable-mdpi/ic_settings_display.png
Normal file
BIN
samples/ApiDemos/res/drawable-mdpi/ic_settings_display.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -21,7 +21,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
<fragment android:name="com.example.android.apis.app.FragmentPreferences$CategoriesFragment"
|
<fragment android:name="com.example.android.apis.preference.FragmentPreferences$CategoriesFragment"
|
||||||
android:id="@+id/categories"
|
android:id="@+id/categories"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0px"
|
android:layout_height="0px"
|
||||||
|
|||||||
@@ -107,8 +107,6 @@
|
|||||||
<string name="fragment1menu">Show fragment 1 menu</string>
|
<string name="fragment1menu">Show fragment 1 menu</string>
|
||||||
<string name="fragment2menu">Show fragment 2 menu</string>
|
<string name="fragment2menu">Show fragment 2 menu</string>
|
||||||
|
|
||||||
<string name="fragment_preferences">App/Fragment/Preferences</string>
|
|
||||||
|
|
||||||
<string name="fragment_retain_instance">App/Fragment/Retain Instance</string>
|
<string name="fragment_retain_instance">App/Fragment/Retain Instance</string>
|
||||||
<string name="fragment_retain_instance_msg">Current progress of retained fragment;
|
<string name="fragment_retain_instance_msg">Current progress of retained fragment;
|
||||||
restarts if fragment is re-created.</string>
|
restarts if fragment is re-created.</string>
|
||||||
@@ -384,12 +382,14 @@
|
|||||||
<!-- app/menu examples strings -->
|
<!-- app/menu examples strings -->
|
||||||
<!-- ============================== -->
|
<!-- ============================== -->
|
||||||
|
|
||||||
<string name="preferences_from_xml">App/Preferences/1. Preferences from XML</string>
|
<string name="preferences_from_xml">Preference/1. Preferences from XML</string>
|
||||||
<string name="launching_preferences">App/Preferences/2. Launching preferences</string>
|
<string name="launching_preferences">Preference/2. Launching preferences</string>
|
||||||
<string name="preference_dependencies">App/Preferences/3. Preference dependencies</string>
|
<string name="preference_dependencies">Preference/3. Preference dependencies</string>
|
||||||
<string name="default_values">App/Preferences/4. Default values</string>
|
<string name="default_values">Preference/4. Default values</string>
|
||||||
<string name="preferences_from_code">App/Preferences/5. Preferences from code</string>
|
<string name="preferences_from_code">Preference/5. Preferences from code</string>
|
||||||
<string name="advanced_preferences">App/Preferences/6. Advanced preferences</string>
|
<string name="advanced_preferences">Preference/6. Advanced preferences</string>
|
||||||
|
<string name="fragment_preferences">Preference/7. Fragment</string>
|
||||||
|
<string name="preference_with_headers">Preference/8. Headers</string>
|
||||||
|
|
||||||
<string name="launch_preference_activity">Launch PreferenceActivity</string>
|
<string name="launch_preference_activity">Launch PreferenceActivity</string>
|
||||||
<string name="counter_value_is">The counter value is</string>
|
<string name="counter_value_is">The counter value is</string>
|
||||||
|
|||||||
31
samples/ApiDemos/res/xml/preference_headers.xml
Normal file
31
samples/ApiDemos/res/xml/preference_headers.xml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2010 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- This is a primitive example showing the different types of preferences available. -->
|
||||||
|
<!-- BEGIN_INCLUDE(headers) -->
|
||||||
|
<PreferenceHeaders
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<Header android:fragment="com.example.android.apis.preference.PreferenceWithHeaders$Prefs1Fragment"
|
||||||
|
android:icon="@drawable/ic_settings_applications"
|
||||||
|
android:title="Prefs 1"
|
||||||
|
android:summary="An example of some preferences." />
|
||||||
|
<Header android:fragment="com.example.android.apis.preference.PreferenceWithHeaders$Prefs2Fragment"
|
||||||
|
android:icon="@drawable/ic_settings_display"
|
||||||
|
android:title="Prefs 2"
|
||||||
|
android:summary="Some other preferences you can see." />
|
||||||
|
</PreferenceHeaders>
|
||||||
|
<!-- END_INCLUDE(headers) -->
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- This is a primitive example showing the different types of preferences available. -->
|
<!-- This is a primitive example showing the different types of preferences available. -->
|
||||||
|
<!-- BEGIN_INCLUDE(preferences) -->
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
@@ -97,3 +98,4 @@
|
|||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
<!-- END_INCLUDE(preferences) -->
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class FragmentDialog extends Activity {
|
|||||||
mStackLevel++;
|
mStackLevel++;
|
||||||
DialogFragment newFragment = new MyDialogFragment(mStackLevel);
|
DialogFragment newFragment = new MyDialogFragment(mStackLevel);
|
||||||
FragmentTransaction ft = openFragmentTransaction();
|
FragmentTransaction ft = openFragmentTransaction();
|
||||||
Fragment prev = this.findFragmentByTag("dialog");
|
Fragment prev = findFragmentByTag("dialog");
|
||||||
if (prev != null) {
|
if (prev != null) {
|
||||||
ft.remove(prev);
|
ft.remove(prev);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.android.apis.app;
|
package com.example.android.apis.preference;
|
||||||
|
|
||||||
import com.example.android.apis.R;
|
import com.example.android.apis.R;
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.android.apis.app;
|
package com.example.android.apis.preference;
|
||||||
|
|
||||||
import com.example.android.apis.ApiDemosApplication;
|
import com.example.android.apis.ApiDemosApplication;
|
||||||
import com.example.android.apis.R;
|
import com.example.android.apis.R;
|
||||||
@@ -14,26 +14,15 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.android.apis.app;
|
package com.example.android.apis.preference;
|
||||||
|
|
||||||
import com.example.android.apis.R;
|
import com.example.android.apis.R;
|
||||||
import com.example.android.apis.Shakespeare;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.ListFragment;
|
import android.app.ListFragment;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.res.TypedArray;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.CheckBoxPreference;
|
|
||||||
import android.preference.EditTextPreference;
|
|
||||||
import android.preference.ListPreference;
|
|
||||||
import android.preference.PreferenceCategory;
|
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
import android.preference.PreferenceScreen;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
@@ -81,6 +70,7 @@ public class FragmentPreferences extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//BEGIN_INCLUDE(fragment)
|
||||||
public static class Prefs1Fragment extends PreferenceFragment {
|
public static class Prefs1Fragment extends PreferenceFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -90,6 +80,7 @@ public class FragmentPreferences extends Activity {
|
|||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//END_INCLUDE(fragment)
|
||||||
|
|
||||||
public static class Prefs2Fragment extends PreferenceFragment {
|
public static class Prefs2Fragment extends PreferenceFragment {
|
||||||
@Override
|
@Override
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.android.apis.app;
|
package com.example.android.apis.preference;
|
||||||
|
|
||||||
import com.example.android.apis.R;
|
import com.example.android.apis.R;
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.android.apis.app;
|
package com.example.android.apis.preference;
|
||||||
|
|
||||||
import com.example.android.apis.R;
|
import com.example.android.apis.R;
|
||||||
|
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.android.apis.preference;
|
||||||
|
|
||||||
|
import com.example.android.apis.R;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceActivity;
|
||||||
|
import android.preference.PreferenceFragment;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Demonstration of PreferenceActivity to make a top-level preference
|
||||||
|
* panel with headers.
|
||||||
|
*/
|
||||||
|
//BEGIN_INCLUDE(activity)
|
||||||
|
public class PreferenceWithHeaders extends PreferenceActivity {
|
||||||
|
@Override
|
||||||
|
public void onBuildHeaders(List<Header> target) {
|
||||||
|
loadHeadersFromResource(R.xml.preference_headers, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Prefs1Fragment extends PreferenceFragment {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// Load the preferences from an XML resource
|
||||||
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Prefs2Fragment extends PreferenceFragment {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// Load the preferences from an XML resource
|
||||||
|
addPreferencesFromResource(R.xml.preference_dependencies);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//END_INCLUDE(activity)
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.android.apis.app;
|
package com.example.android.apis.preference;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.android.apis.app;
|
package com.example.android.apis.preference;
|
||||||
|
|
||||||
import com.example.android.apis.R;
|
import com.example.android.apis.R;
|
||||||
|
|
||||||
Reference in New Issue
Block a user