diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml
index 4717a40cf..473a3f5e4 100644
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -660,78 +660,6 @@
Jump
Dive
-
-
-
-
- Preference/1. Preferences from XML
- Preference/2. Launching preferences
- Preference/3. Preference dependencies
- Preference/4. Default values
- Preference/5. Preferences from code
- Preference/6. Advanced preferences
- Preference/7. Fragment
- Preference/8. Headers
- Preference/9. Switch
-
- Launch PreferenceActivity
- The counter value is
-
- In-line preferences
- Dialog-based preferences
- Launch preferences
- Preference attributes
-
- Checkbox preference
- This is a checkbox
-
- Switch preference
- This is a switch
- This is a switch with custom text
-
- Yes or no preference
- An example that uses a yes/no dialog
- Do you like bananas?
-
- Edit text preference
- An example that uses an edit text dialog
- Enter your favorite animal
-
- List preference
- An example that uses a list dialog
- Choose one
-
- Screen preference
- Shows another screen of preferences
-
- Fragment preference
- Shows another fragment of preferences
-
- Toggle preference
- Preference that is on the next screen but same hierarchy
-
- Intent preference
- Launches an Activity from an Intent
-
- My preference
- This is a custom counter preference
-
- Haunted preference
- I\'m on! :)
- I\'m off! :(
-
- Parent checkbox preference
- This is visually a parent
- Child checkbox preference
- This is visually a child
-
- Example preference dependency
- WiFi
- WiFi settings
-
- beta
- Default value
-
diff --git a/samples/ApiDemos/res/xml/advanced_preferences.xml b/samples/ApiDemos/res/xml/advanced_preferences.xml
deleted file mode 100644
index dd6de31d8..000000000
--- a/samples/ApiDemos/res/xml/advanced_preferences.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/ApiDemos/res/xml/default_values.xml b/samples/ApiDemos/res/xml/default_values.xml
deleted file mode 100644
index ef06c3eaf..000000000
--- a/samples/ApiDemos/res/xml/default_values.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/ApiDemos/res/xml/fragmented_preferences.xml b/samples/ApiDemos/res/xml/fragmented_preferences.xml
deleted file mode 100644
index 71cb21cc6..000000000
--- a/samples/ApiDemos/res/xml/fragmented_preferences.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/ApiDemos/res/xml/fragmented_preferences_inner.xml b/samples/ApiDemos/res/xml/fragmented_preferences_inner.xml
deleted file mode 100644
index f462c5759..000000000
--- a/samples/ApiDemos/res/xml/fragmented_preferences_inner.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/samples/ApiDemos/res/xml/preference_dependencies.xml b/samples/ApiDemos/res/xml/preference_dependencies.xml
deleted file mode 100644
index 5eae5803f..000000000
--- a/samples/ApiDemos/res/xml/preference_dependencies.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/ApiDemos/res/xml/preference_headers.xml b/samples/ApiDemos/res/xml/preference_headers.xml
deleted file mode 100644
index 7dcc5311e..000000000
--- a/samples/ApiDemos/res/xml/preference_headers.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/ApiDemos/res/xml/preference_switch b/samples/ApiDemos/res/xml/preference_switch
deleted file mode 100644
index fceb3a146..000000000
--- a/samples/ApiDemos/res/xml/preference_switch
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/ApiDemos/res/xml/preferences.xml b/samples/ApiDemos/res/xml/preferences.xml
deleted file mode 100644
index 6f3faee08..000000000
--- a/samples/ApiDemos/res/xml/preferences.xml
+++ /dev/null
@@ -1,101 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/samples/ApiDemos/src/com/example/android/apis/preference/AdvancedPreferences.java b/samples/ApiDemos/src/com/example/android/apis/preference/AdvancedPreferences.java
deleted file mode 100644
index 0328b03f6..000000000
--- a/samples/ApiDemos/src/com/example/android/apis/preference/AdvancedPreferences.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2007 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.content.SharedPreferences;
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.os.Bundle;
-import android.os.Handler;
-import android.preference.PreferenceActivity;
-import android.preference.CheckBoxPreference;
-import android.widget.Toast;
-
-/**
- * Example that shows finding a preference from the hierarchy and a custom preference type.
- */
-public class AdvancedPreferences extends PreferenceActivity implements OnSharedPreferenceChangeListener {
- public static final String KEY_MY_PREFERENCE = "my_preference";
- public static final String KEY_ADVANCED_CHECKBOX_PREFERENCE = "advanced_checkbox_preference";
-
- private CheckBoxPreference mCheckBoxPreference;
- private Handler mHandler = new Handler();
-
- /**
- * This is a simple example of controlling a preference from code.
- */
- private Runnable mForceCheckBoxRunnable = new Runnable() {
- public void run() {
- if (mCheckBoxPreference != null) {
- mCheckBoxPreference.setChecked(!mCheckBoxPreference.isChecked());
- }
-
- // Force toggle again in a second
- mHandler.postDelayed(this, 1000);
- }
- };
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Load the XML preferences file
- addPreferencesFromResource(R.xml.advanced_preferences);
-
- // Get a reference to the checkbox preference
- mCheckBoxPreference = (CheckBoxPreference)getPreferenceScreen().findPreference(
- KEY_ADVANCED_CHECKBOX_PREFERENCE);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- // Start the force toggle
- mForceCheckBoxRunnable.run();
-
- // Set up a listener whenever a key changes
- getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
- }
-
- @Override
- protected void onPause() {
- super.onPause();
-
- // Unregister the listener whenever a key changes
- getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
-
- mHandler.removeCallbacks(mForceCheckBoxRunnable);
- }
-
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- // Let's do something when my counter preference value changes
- if (key.equals(KEY_MY_PREFERENCE)) {
- Toast.makeText(this, "Thanks! You increased my count to "
- + sharedPreferences.getInt(key, 0), Toast.LENGTH_SHORT).show();
- }
- }
-
-}
diff --git a/samples/ApiDemos/src/com/example/android/apis/preference/DefaultValues.java b/samples/ApiDemos/src/com/example/android/apis/preference/DefaultValues.java
deleted file mode 100644
index 84cd5b2f2..000000000
--- a/samples/ApiDemos/src/com/example/android/apis/preference/DefaultValues.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2007 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.content.Context;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.preference.PreferenceActivity;
-import android.preference.PreferenceManager;
-
-/**
- * This activity is an example of a simple settings screen that has default
- * values.
- *
- * In order for the default values to be populated into the
- * {@link SharedPreferences} (from the preferences XML file), the client must
- * call
- * {@link PreferenceManager#setDefaultValues(android.content.Context, int, boolean)}.
- *
- * This should be called early, typically when the application is first created.
- * An easy way to do this is to have a common function for retrieving the
- * SharedPreferences that takes care of calling it.
- */
-public class DefaultValues extends PreferenceActivity {
- // This is the global (to the .apk) name under which we store these
- // preferences. We want this to be unique from other preferences so that
- // we do not have unexpected name conflicts, and the framework can correctly
- // determine whether these preferences' defaults have already been written.
- static final String PREFS_NAME = "defaults";
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- getPrefs(this);
- getPreferenceManager().setSharedPreferencesName(PREFS_NAME);
- addPreferencesFromResource(R.xml.default_values);
- }
-
- static SharedPreferences getPrefs(Context context) {
- PreferenceManager.setDefaultValues(context, PREFS_NAME, MODE_PRIVATE,
- R.xml.default_values, false);
- return context.getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
- }
-}
diff --git a/samples/ApiDemos/src/com/example/android/apis/preference/FragmentPreferences.java b/samples/ApiDemos/src/com/example/android/apis/preference/FragmentPreferences.java
deleted file mode 100644
index 6e9c6147a..000000000
--- a/samples/ApiDemos/src/com/example/android/apis/preference/FragmentPreferences.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.app.Activity;
-import android.os.Bundle;
-import android.preference.PreferenceFragment;
-
-/**
- * Demonstration of PreferenceFragment, showing a single fragment in an
- * activity.
- */
-public class FragmentPreferences extends Activity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Display the fragment as the main content.
- getFragmentManager().beginTransaction().replace(android.R.id.content,
- new PrefsFragment()).commit();
- }
-
-//BEGIN_INCLUDE(fragment)
- public static class PrefsFragment extends PreferenceFragment {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Load the preferences from an XML resource
- addPreferencesFromResource(R.xml.preferences);
- }
- }
-//END_INCLUDE(fragment)
-}
diff --git a/samples/ApiDemos/src/com/example/android/apis/preference/LaunchingPreferences.java b/samples/ApiDemos/src/com/example/android/apis/preference/LaunchingPreferences.java
deleted file mode 100644
index 573330c96..000000000
--- a/samples/ApiDemos/src/com/example/android/apis/preference/LaunchingPreferences.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2007 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.app.Activity;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.LinearLayout.LayoutParams;
-
-/**
- * Demonstrates launching a PreferenceActivity and grabbing a value it saved.
- */
-public class LaunchingPreferences extends Activity implements OnClickListener {
-
- private static final int REQUEST_CODE_PREFERENCES = 1;
-
- private TextView mCounterText;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- /*
- * These preferences have defaults, so before using them go apply those
- * defaults. This will only execute once -- when the defaults are applied
- * a boolean preference is set so they will not be applied again.
- */
- PreferenceManager.setDefaultValues(this, R.xml.advanced_preferences, false);
-
- // Simple layout
- LinearLayout layout = new LinearLayout(this);
- layout.setOrientation(LinearLayout.VERTICAL);
- setContentView(layout);
-
- // Create a simple button that will launch the preferences
- Button launchPreferences = new Button(this);
- launchPreferences.setText(getString(R.string.launch_preference_activity));
- launchPreferences.setOnClickListener(this);
- layout.addView(launchPreferences, new LayoutParams(LayoutParams.MATCH_PARENT,
- LayoutParams.WRAP_CONTENT));
-
- mCounterText = new TextView(this);
- layout.addView(mCounterText, new LayoutParams(LayoutParams.MATCH_PARENT,
- LayoutParams.WRAP_CONTENT));
-
- updateCounterText();
- }
-
- public void onClick(View v) {
-
- // When the button is clicked, launch an activity through this intent
- Intent launchPreferencesIntent = new Intent().setClass(this, AdvancedPreferences.class);
-
- // Make it a subactivity so we know when it returns
- startActivityForResult(launchPreferencesIntent, REQUEST_CODE_PREFERENCES);
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
-
- // The preferences returned if the request code is what we had given
- // earlier in startSubActivity
- if (requestCode == REQUEST_CODE_PREFERENCES) {
- // Read a sample value they have set
- updateCounterText();
- }
- }
-
- private void updateCounterText() {
- // Since we're in the same package, we can use this context to get
- // the default shared preferences
- SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
- final int counter = sharedPref.getInt(AdvancedPreferences.KEY_MY_PREFERENCE, 0);
- mCounterText.setText(getString(R.string.counter_value_is) + " " + counter);
- }
-}
diff --git a/samples/ApiDemos/src/com/example/android/apis/preference/MyPreference.java b/samples/ApiDemos/src/com/example/android/apis/preference/MyPreference.java
deleted file mode 100644
index aeb8bf9e9..000000000
--- a/samples/ApiDemos/src/com/example/android/apis/preference/MyPreference.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2007 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.content.Context;
-import android.content.res.TypedArray;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.preference.Preference;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.TextView;
-
-/**
- * This is an example of a custom preference type. The preference counts the
- * number of clicks it has received and stores/retrieves it from the storage.
- */
-public class MyPreference extends Preference {
- private int mClickCounter;
-
- // This is the constructor called by the inflater
- public MyPreference(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- setWidgetLayoutResource(R.layout.preference_widget_mypreference);
- }
-
- @Override
- protected void onBindView(View view) {
- super.onBindView(view);
-
- // Set our custom views inside the layout
- final TextView myTextView = (TextView) view.findViewById(R.id.mypreference_widget);
- if (myTextView != null) {
- myTextView.setText(String.valueOf(mClickCounter));
- }
- }
-
- @Override
- protected void onClick() {
- int newValue = mClickCounter + 1;
- // Give the client a chance to ignore this change if they deem it
- // invalid
- if (!callChangeListener(newValue)) {
- // They don't want the value to be set
- return;
- }
-
- // Increment counter
- mClickCounter = newValue;
-
- // Save to persistent storage (this method will make sure this
- // preference should be persistent, along with other useful checks)
- persistInt(mClickCounter);
-
- // Data has changed, notify so UI can be refreshed!
- notifyChanged();
- }
-
- @Override
- protected Object onGetDefaultValue(TypedArray a, int index) {
- // This preference type's value type is Integer, so we read the default
- // value from the attributes as an Integer.
- return a.getInteger(index, 0);
- }
-
- @Override
- protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
- if (restoreValue) {
- // Restore state
- mClickCounter = getPersistedInt(mClickCounter);
- } else {
- // Set state
- int value = (Integer) defaultValue;
- mClickCounter = value;
- persistInt(value);
- }
- }
-
- @Override
- protected Parcelable onSaveInstanceState() {
- /*
- * Suppose a client uses this preference type without persisting. We
- * must save the instance state so it is able to, for example, survive
- * orientation changes.
- */
-
- final Parcelable superState = super.onSaveInstanceState();
- if (isPersistent()) {
- // No need to save instance state since it's persistent
- return superState;
- }
-
- // Save the instance state
- final SavedState myState = new SavedState(superState);
- myState.clickCounter = mClickCounter;
- return myState;
- }
-
- @Override
- protected void onRestoreInstanceState(Parcelable state) {
- if (!state.getClass().equals(SavedState.class)) {
- // Didn't save state for us in onSaveInstanceState
- super.onRestoreInstanceState(state);
- return;
- }
-
- // Restore the instance state
- SavedState myState = (SavedState) state;
- super.onRestoreInstanceState(myState.getSuperState());
- mClickCounter = myState.clickCounter;
- notifyChanged();
- }
-
- /**
- * SavedState, a subclass of {@link BaseSavedState}, will store the state
- * of MyPreference, a subclass of Preference.
- *
- * It is important to always call through to super methods.
- */
- private static class SavedState extends BaseSavedState {
- int clickCounter;
-
- public SavedState(Parcel source) {
- super(source);
-
- // Restore the click counter
- clickCounter = source.readInt();
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- super.writeToParcel(dest, flags);
-
- // Save the click counter
- dest.writeInt(clickCounter);
- }
-
- public SavedState(Parcelable superState) {
- super(superState);
- }
-
- public static final Parcelable.Creator CREATOR =
- new Parcelable.Creator() {
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
-
-}
diff --git a/samples/ApiDemos/src/com/example/android/apis/preference/PreferenceDependencies.java b/samples/ApiDemos/src/com/example/android/apis/preference/PreferenceDependencies.java
deleted file mode 100644
index 3aa4e390e..000000000
--- a/samples/ApiDemos/src/com/example/android/apis/preference/PreferenceDependencies.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2007 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;
-
-public class PreferenceDependencies extends PreferenceActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- addPreferencesFromResource(R.xml.preference_dependencies);
- }
-
-}
diff --git a/samples/ApiDemos/src/com/example/android/apis/preference/PreferenceWithHeaders.java b/samples/ApiDemos/src/com/example/android/apis/preference/PreferenceWithHeaders.java
deleted file mode 100644
index b4dbdb41e..000000000
--- a/samples/ApiDemos/src/com/example/android/apis/preference/PreferenceWithHeaders.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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 android.preference.PreferenceManager;
-import android.util.Log;
-import android.widget.Button;
-
-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
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Add a button to the header list.
- if (hasHeaders()) {
- Button button = new Button(this);
- button.setText("Some action");
- setListFooter(button);
- }
- }
-
- /**
- * Populate the activity with the top-level headers.
- */
- @Override
- public void onBuildHeaders(List target) {
- loadHeadersFromResource(R.xml.preference_headers, target);
- }
-
- /**
- * This fragment shows the preferences for the first header.
- */
- public static class Prefs1Fragment extends PreferenceFragment {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Make sure default values are applied. In a real app, you would
- // want this in a shared function that is used to retrieve the
- // SharedPreferences wherever they are needed.
- PreferenceManager.setDefaultValues(getActivity(),
- R.xml.advanced_preferences, false);
-
- // Load the preferences from an XML resource
- addPreferencesFromResource(R.xml.fragmented_preferences);
- }
- }
-
- /**
- * This fragment contains a second-level set of preference that you
- * can get to by tapping an item in the first preferences fragment.
- */
- public static class Prefs1FragmentInner extends PreferenceFragment {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Can retrieve arguments from preference XML.
- Log.i("args", "Arguments: " + getArguments());
-
- // Load the preferences from an XML resource
- addPreferencesFromResource(R.xml.fragmented_preferences_inner);
- }
- }
-
- /**
- * This fragment shows the preferences for the second header.
- */
- public static class Prefs2Fragment extends PreferenceFragment {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Can retrieve arguments from headers XML.
- Log.i("args", "Arguments: " + getArguments());
-
- // Load the preferences from an XML resource
- addPreferencesFromResource(R.xml.preference_dependencies);
- }
- }
-}
-//END_INCLUDE(activity)
diff --git a/samples/ApiDemos/src/com/example/android/apis/preference/PreferencesFromCode.java b/samples/ApiDemos/src/com/example/android/apis/preference/PreferencesFromCode.java
deleted file mode 100644
index f4bb310db..000000000
--- a/samples/ApiDemos/src/com/example/android/apis/preference/PreferencesFromCode.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2007 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.content.Intent;
-import android.content.res.TypedArray;
-import android.net.Uri;
-import android.os.Bundle;
-import android.preference.CheckBoxPreference;
-import android.preference.EditTextPreference;
-import android.preference.ListPreference;
-import android.preference.PreferenceActivity;
-import android.preference.PreferenceCategory;
-import android.preference.PreferenceScreen;
-import android.preference.SwitchPreference;
-
-public class PreferencesFromCode extends PreferenceActivity {
-
- private static final String PARENT_CHECKBOX_PREFERENCE = "parent_checkbox_preference";
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);
- setPreferenceScreen(root);
- populatePreferenceHierarchy(root);
- }
-
- private void populatePreferenceHierarchy(PreferenceScreen root) {
- // Inline preferences
- PreferenceCategory inlinePrefCat = new PreferenceCategory(this);
- inlinePrefCat.setTitle(R.string.inline_preferences);
- root.addPreference(inlinePrefCat);
-
- // 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);
- dialogBasedPrefCat.setTitle(R.string.dialog_based_preferences);
- root.addPreference(dialogBasedPrefCat);
-
- // Edit text preference
- EditTextPreference editTextPref = new EditTextPreference(this);
- editTextPref.setDialogTitle(R.string.dialog_title_edittext_preference);
- editTextPref.setKey("edittext_preference");
- editTextPref.setTitle(R.string.title_edittext_preference);
- editTextPref.setSummary(R.string.summary_edittext_preference);
- dialogBasedPrefCat.addPreference(editTextPref);
-
- // List preference
- ListPreference listPref = new ListPreference(this);
- listPref.setEntries(R.array.entries_list_preference);
- listPref.setEntryValues(R.array.entryvalues_list_preference);
- listPref.setDialogTitle(R.string.dialog_title_list_preference);
- listPref.setKey("list_preference");
- listPref.setTitle(R.string.title_list_preference);
- listPref.setSummary(R.string.summary_list_preference);
- dialogBasedPrefCat.addPreference(listPref);
-
- // Launch preferences
- PreferenceCategory launchPrefCat = new PreferenceCategory(this);
- launchPrefCat.setTitle(R.string.launch_preferences);
- root.addPreference(launchPrefCat);
-
- /*
- * The Preferences screenPref serves as a screen break (similar to page
- * break in word processing). Like for other preference types, we assign
- * a key here so that it is able to save and restore its instance state.
- */
- // Screen preference
- PreferenceScreen screenPref = getPreferenceManager().createPreferenceScreen(this);
- screenPref.setKey("screen_preference");
- screenPref.setTitle(R.string.title_screen_preference);
- screenPref.setSummary(R.string.summary_screen_preference);
- launchPrefCat.addPreference(screenPref);
-
- /*
- * You can add more preferences to screenPref that will be shown on the
- * next screen.
- */
-
- // Example of next screen toggle preference
- CheckBoxPreference nextScreenCheckBoxPref = new CheckBoxPreference(this);
- nextScreenCheckBoxPref.setKey("next_screen_toggle_preference");
- nextScreenCheckBoxPref.setTitle(R.string.title_next_screen_toggle_preference);
- nextScreenCheckBoxPref.setSummary(R.string.summary_next_screen_toggle_preference);
- screenPref.addPreference(nextScreenCheckBoxPref);
-
- // Intent preference
- PreferenceScreen intentPref = getPreferenceManager().createPreferenceScreen(this);
- intentPref.setIntent(new Intent().setAction(Intent.ACTION_VIEW)
- .setData(Uri.parse("http://www.android.com")));
- intentPref.setTitle(R.string.title_intent_preference);
- intentPref.setSummary(R.string.summary_intent_preference);
- launchPrefCat.addPreference(intentPref);
-
- // Preference attributes
- PreferenceCategory prefAttrsCat = new PreferenceCategory(this);
- prefAttrsCat.setTitle(R.string.preference_attributes);
- root.addPreference(prefAttrsCat);
-
- // Visual parent toggle preference
- CheckBoxPreference parentCheckBoxPref = new CheckBoxPreference(this);
- parentCheckBoxPref.setTitle(R.string.title_parent_preference);
- parentCheckBoxPref.setSummary(R.string.summary_parent_preference);
- prefAttrsCat.addPreference(parentCheckBoxPref);
- parentCheckBoxPref.setKey(PARENT_CHECKBOX_PREFERENCE);
-
- // Visual child toggle preference
- // See res/values/attrs.xml for the that defines
- // TogglePrefAttrs.
- TypedArray a = obtainStyledAttributes(R.styleable.TogglePrefAttrs);
- CheckBoxPreference childCheckBoxPref = new CheckBoxPreference(this);
- childCheckBoxPref.setTitle(R.string.title_child_preference);
- childCheckBoxPref.setSummary(R.string.summary_child_preference);
- childCheckBoxPref.setLayoutResource(
- a.getResourceId(R.styleable.TogglePrefAttrs_android_preferenceLayoutChild,
- 0));
- prefAttrsCat.addPreference(childCheckBoxPref);
- childCheckBoxPref.setDependency(PARENT_CHECKBOX_PREFERENCE);
- a.recycle();
- }
-}
diff --git a/samples/ApiDemos/src/com/example/android/apis/preference/PreferencesFromXml.java b/samples/ApiDemos/src/com/example/android/apis/preference/PreferencesFromXml.java
deleted file mode 100644
index 868e33c69..000000000
--- a/samples/ApiDemos/src/com/example/android/apis/preference/PreferencesFromXml.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2007 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;
-
-public class PreferencesFromXml extends PreferenceActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Load the preferences from an XML resource
- addPreferencesFromResource(R.xml.preferences);
- }
-
-}
diff --git a/samples/ApiDemos/src/com/example/android/apis/preference/SwitchPreference.java b/samples/ApiDemos/src/com/example/android/apis/preference/SwitchPreference.java
deleted file mode 100644
index 191c6ac7e..000000000
--- a/samples/ApiDemos/src/com/example/android/apis/preference/SwitchPreference.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2007 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.PreferenceManager;
-
-public class SwitchPreference extends PreferenceActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- PreferenceManager.setDefaultValues(this, "switch", MODE_PRIVATE,
- R.xml.default_values, false);
-
- // Load the preferences from an XML resource
- getPreferenceManager().setSharedPreferencesName("switch");
- addPreferencesFromResource(R.xml.preference_switch);
- }
-}