Merge "Fix Development app to use netd for routes" into honeycomb-LTE
diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml
index 915b56f..c570322 100644
--- a/samples/ApiDemos/AndroidManifest.xml
+++ b/samples/ApiDemos/AndroidManifest.xml
@@ -312,15 +312,6 @@
<activity android:name=".app.FragmentLayout$DetailsActivity"
android:enabled="@bool/atLeastHoneycomb" />
- <activity android:name=".app.FragmentListCursorLoader"
- android:label="@string/fragment_list_cursor_loader"
- android:enabled="@bool/atLeastHoneycomb">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
-
<activity android:name=".app.FragmentListArray"
android:label="@string/fragment_list_array"
android:enabled="@bool/atLeastHoneycomb">
@@ -425,14 +416,6 @@
</intent-filter>
</activity>
- <activity android:name=".support.app.FragmentListCursorLoaderSupport"
- android:label="@string/fragment_list_cursor_loader_support">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.SAMPLE_CODE" />
- </intent-filter>
- </activity>
-
<activity android:name=".support.app.FragmentListArraySupport"
android:label="@string/fragment_list_array_support">
<intent-filter>
@@ -475,8 +458,34 @@
</intent-filter>
</activity>
+ <activity android:name=".support.app.FragmentPagerSupport"
+ android:label="@string/fragment_pager_support">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
<!-- Loader Samples -->
+ <activity android:name=".app.LoaderCursor"
+ android:label="@string/loader_cursor"
+ android:enabled="@bool/atLeastHoneycomb">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".app.LoaderCustom"
+ android:label="@string/loader_custom"
+ android:enabled="@bool/atLeastHoneycomb">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
<!-- BEGIN_INCLUDE(loader_throttle) -->
<activity android:name=".app.LoaderThrottle"
android:label="@string/loader_throttle"
@@ -493,6 +502,14 @@
<!-- Fragment Support Samples -->
+ <activity android:name=".support.app.LoaderCursorSupport"
+ android:label="@string/loader_cursor_support">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
<activity android:name=".support.app.LoaderThrottleSupport"
android:label="@string/loader_throttle_support">
<intent-filter>
@@ -1010,6 +1027,16 @@
</intent-filter>
</activity>
+ <activity android:name=".content.ResourcesWidthAndHeight"
+ android:label="@string/activity_resources_width_and_height"
+ android:enabled="@bool/atLeastIceCreamSandwich">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.SAMPLE_CODE" />
+ <category android:name="android.intent.category.EMBED" />
+ </intent-filter>
+ </activity>
+
<activity android:name=".content.ReadAsset" android:label="@string/activity_read_asset">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
diff --git a/samples/ApiDemos/res/layout-h420dp/resources_height.xml b/samples/ApiDemos/res/layout-h420dp/resources_height.xml
new file mode 100644
index 0000000..115a731
--- /dev/null
+++ b/samples/ApiDemos/res/layout-h420dp/resources_height.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<!-- Part of resources_width_and_height that varies based on height. -->
+
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+ <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
+ android:orientation="vertical">
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1" android:padding="4dp"
+ android:background="#8000ff00">
+ <include layout="@layout/resources_width" />
+ </FrameLayout>
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1" android:padding="4dp"
+ android:background="#80ff0000">
+ <include layout="@layout/resources_width" />
+ </FrameLayout>
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1" android:padding="4dp"
+ android:background="#8000ff00">
+ <include layout="@layout/resources_width" />
+ </FrameLayout>
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1" android:padding="4dp"
+ android:background="#80ff0000">
+ <include layout="@layout/resources_width" />
+ </FrameLayout>
+ </LinearLayout>
+</merge>
diff --git a/samples/ApiDemos/res/layout-h670dp/resources_height.xml b/samples/ApiDemos/res/layout-h670dp/resources_height.xml
new file mode 100644
index 0000000..3130a91
--- /dev/null
+++ b/samples/ApiDemos/res/layout-h670dp/resources_height.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<!-- Part of resources_width_and_height that varies based on height. -->
+
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+ <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
+ android:orientation="vertical">
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1" android:padding="4dp"
+ android:background="#8000ff00">
+ <include layout="@layout/resources_width" />
+ </FrameLayout>
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1" android:padding="4dp"
+ android:background="#80ff0000">
+ <include layout="@layout/resources_width" />
+ </FrameLayout>
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1" android:padding="4dp"
+ android:background="#8000ff00">
+ <include layout="@layout/resources_width" />
+ </FrameLayout>
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1" android:padding="4dp"
+ android:background="#80ff0000">
+ <include layout="@layout/resources_width" />
+ </FrameLayout>
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1" android:padding="4dp"
+ android:background="#8000ff00">
+ <include layout="@layout/resources_width" />
+ </FrameLayout>
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1" android:padding="4dp"
+ android:background="#80ff0000">
+ <include layout="@layout/resources_width" />
+ </FrameLayout>
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1" android:padding="4dp"
+ android:background="#8000ff00">
+ <include layout="@layout/resources_width" />
+ </FrameLayout>
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1" android:padding="4dp"
+ android:background="#80ff0000">
+ <include layout="@layout/resources_width" />
+ </FrameLayout>
+ </LinearLayout>
+</merge>
diff --git a/samples/ApiDemos/res/layout-w420dp/resources_width.xml b/samples/ApiDemos/res/layout-w420dp/resources_width.xml
new file mode 100644
index 0000000..1edffe3
--- /dev/null
+++ b/samples/ApiDemos/res/layout-w420dp/resources_width.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<!-- Part of resources_width_and_height that varies based on width. -->
+
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+ <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
+ android:orientation="horizontal">
+ <TextView android:layout_width="0px" android:layout_height="match_parent"
+ android:layout_weight="1" android:gravity="center_horizontal"
+ android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
+ android:background="#800000ff" android:text="w420dp Width\n#1">
+ </TextView>
+ <TextView android:layout_width="0px" android:layout_height="match_parent"
+ android:layout_weight="1" android:gravity="center_horizontal"
+ android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
+ android:background="#800000ff" android:text="w420dp Width\n#2">
+ </TextView>
+ <TextView android:layout_width="0px" android:layout_height="match_parent"
+ android:layout_weight="1" android:gravity="center_horizontal"
+ android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
+ android:background="#800000ff" android:text="w420dp Width\n#3">
+ </TextView>
+ <TextView android:layout_width="0px" android:layout_height="match_parent"
+ android:layout_weight="1" android:gravity="center_horizontal"
+ android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
+ android:background="#800000ff" android:text="w420dp Width\n#4">
+ </TextView>
+ </LinearLayout>
+</merge>
diff --git a/samples/ApiDemos/res/layout-w720dp/resources_width.xml b/samples/ApiDemos/res/layout-w720dp/resources_width.xml
new file mode 100644
index 0000000..8625c82
--- /dev/null
+++ b/samples/ApiDemos/res/layout-w720dp/resources_width.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<!-- Part of resources_width_and_height that varies based on width. -->
+
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+ <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
+ android:orientation="horizontal">
+ <TextView android:layout_width="0px" android:layout_height="match_parent"
+ android:layout_weight="1" android:gravity="center_horizontal"
+ android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
+ android:background="#800000ff" android:text="w720dp Width\n#1">
+ </TextView>
+ <TextView android:layout_width="0px" android:layout_height="match_parent"
+ android:layout_weight="1" android:gravity="center_horizontal"
+ android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
+ android:background="#800000ff" android:text="w720dp Width\n#2">
+ </TextView>
+ <TextView android:layout_width="0px" android:layout_height="match_parent"
+ android:layout_weight="1" android:gravity="center_horizontal"
+ android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
+ android:background="#800000ff" android:text="w720dp Width\n#3">
+ </TextView>
+ <TextView android:layout_width="0px" android:layout_height="match_parent"
+ android:layout_weight="1" android:gravity="center_horizontal"
+ android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
+ android:background="#800000ff" android:text="w720dp Width\n#4">
+ </TextView>
+ <TextView android:layout_width="0px" android:layout_height="match_parent"
+ android:layout_weight="1" android:gravity="center_horizontal"
+ android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
+ android:background="#800000ff" android:text="w720dp Width\n#5">
+ </TextView>
+ <TextView android:layout_width="0px" android:layout_height="match_parent"
+ android:layout_weight="1" android:gravity="center_horizontal"
+ android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
+ android:background="#800000ff" android:text="w720dp Width\n#6">
+ </TextView>
+ <TextView android:layout_width="0px" android:layout_height="match_parent"
+ android:layout_weight="1" android:gravity="center_horizontal"
+ android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
+ android:background="#800000ff" android:text="w720dp Width\n#7">
+ </TextView>
+ <TextView android:layout_width="0px" android:layout_height="match_parent"
+ android:layout_weight="1" android:gravity="center_horizontal"
+ android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
+ android:background="#800000ff" android:text="w720dp Width\n#8">
+ </TextView>
+ </LinearLayout>
+</merge>
diff --git a/samples/ApiDemos/res/layout/fragment_pager.xml b/samples/ApiDemos/res/layout/fragment_pager.xml
new file mode 100644
index 0000000..3867f46
--- /dev/null
+++ b/samples/ApiDemos/res/layout/fragment_pager.xml
@@ -0,0 +1,37 @@
+<?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.
+-->
+
+<!-- Top-level content view for the simple fragment sample. -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:padding="4dip"
+ android:gravity="center_horizontal"
+ android:layout_width="match_parent" android:layout_height="match_parent">
+
+ <android.support.v4.app.FragmentPager
+ android:id="@+id/pager"
+ android:layout_width="match_parent"
+ android:layout_height="0px"
+ android:layout_weight="1">
+ </android.support.v4.app.FragmentPager>
+
+ <Button android:id="@+id/new_fragment"
+ android:layout_width="wrap_content" android:layout_height="wrap_content"
+ android:layout_weight="0"
+ android:text="@string/new_fragment">
+ <requestFocus />
+ </Button>
+</LinearLayout>
diff --git a/samples/ApiDemos/res/layout/fragment_pager_list.xml b/samples/ApiDemos/res/layout/fragment_pager_list.xml
new file mode 100644
index 0000000..bbe7b1d
--- /dev/null
+++ b/samples/ApiDemos/res/layout/fragment_pager_list.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@android:drawable/gallery_thumb">
+
+ <TextView android:id="@+id/text"
+ android:layout_width="match_parent" android:layout_height="wrap_content"
+ android:gravity="center_vertical|center_horizontal"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/hello_world"/>
+
+ <!-- The frame layout is here since we will be showing either
+ the empty view or the list view. -->
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="0dip"
+ android:layout_weight="1" >
+ <!-- Here is the list. Since we are using a ListActivity, we
+ have to call it "@android:id/list" so ListActivity will
+ find it -->
+ <ListView android:id="@android:id/list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:drawSelectorOnTop="false"/>
+
+ <!-- Here is the view to show if the list is emtpy -->
+ <TextView android:id="@android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="No items."/>
+
+ </FrameLayout>
+
+</LinearLayout>
diff --git a/samples/ApiDemos/res/layout/resources_height.xml b/samples/ApiDemos/res/layout/resources_height.xml
new file mode 100644
index 0000000..1e219bf
--- /dev/null
+++ b/samples/ApiDemos/res/layout/resources_height.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<!-- Part of resources_width_and_height that varies based on height. -->
+
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+ <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
+ android:orientation="vertical">
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1" android:padding="4dp"
+ android:background="#8000ff00">
+ <include layout="@layout/resources_width" />
+ </FrameLayout>
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1" android:padding="4dp"
+ android:background="#80ff0000">
+ <include layout="@layout/resources_width" />
+ </FrameLayout>
+ </LinearLayout>
+</merge>
diff --git a/samples/ApiDemos/res/layout/resources_width.xml b/samples/ApiDemos/res/layout/resources_width.xml
new file mode 100644
index 0000000..a05a6e8
--- /dev/null
+++ b/samples/ApiDemos/res/layout/resources_width.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<!-- Part of resources_width_and_height that varies based on width. -->
+
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
+ <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
+ android:orientation="horizontal">
+ <TextView android:layout_width="0px" android:layout_height="match_parent"
+ android:layout_weight="1" android:gravity="center_horizontal"
+ android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
+ android:background="#800000ff" android:text="Default Width\n#1">
+ </TextView>
+ <TextView android:layout_width="0px" android:layout_height="match_parent"
+ android:layout_weight="1" android:gravity="center_horizontal"
+ android:layout_marginLeft="4dp" android:layout_marginRight="4dp"
+ android:background="#800000ff" android:text="Default Width\n#2">
+ </TextView>
+ </LinearLayout>
+</merge>
diff --git a/samples/ApiDemos/res/layout/resources_width_and_height.xml b/samples/ApiDemos/res/layout/resources_width_and_height.xml
new file mode 100644
index 0000000..8649dbe
--- /dev/null
+++ b/samples/ApiDemos/res/layout/resources_width_and_height.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<!-- Demonstrates using -wNNNdp and -hNNNdp resource configs. -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent" android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <TextView android:layout_width="match_parent" android:layout_height="wrap_content"
+ android:layout_weight="0" android:gravity="center_horizontal"
+ android:paddingTop="8dp" android:paddingBottom="8dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/resources_width_and_height_description"/>
+
+ <FrameLayout android:layout_width="match_parent" android:layout_height="0px"
+ android:layout_weight="1"
+ android:background="@android:drawable/gallery_thumb">
+ <include layout="@layout/resources_height" />
+ </FrameLayout>
+
+</LinearLayout>
diff --git a/samples/ApiDemos/res/layout/save_restore_state.xml b/samples/ApiDemos/res/layout/save_restore_state.xml
index 4b489ed..0871dbb 100644
--- a/samples/ApiDemos/res/layout/save_restore_state.xml
+++ b/samples/ApiDemos/res/layout/save_restore_state.xml
@@ -17,42 +17,42 @@
<!-- Demonstrates saving and restoring activity state.
See corresponding Java code com.android.sdk.app.SaveRestoreState.java. -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:padding="4dip"
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
+ <LinearLayout android:orientation="vertical" android:padding="4dip"
+ android:layout_width="match_parent" android:layout_height="wrap_content">
- <TextView android:id="@+id/msg"
- android:layout_width="match_parent" android:layout_height="wrap_content"
- android:layout_weight="0"
- android:paddingBottom="4dip" />
+ <TextView android:id="@+id/msg"
+ android:layout_width="match_parent" android:layout_height="wrap_content"
+ android:layout_weight="0" android:textAppearance="?android:attr/textAppearanceMedium"
+ android:paddingBottom="4dip" />
- <TextView
- android:layout_width="match_parent" android:layout_height="wrap_content"
- android:layout_weight="0"
- android:paddingBottom="4dip"
- android:text="@string/saves_state"/>
+ <TextView
+ android:layout_width="match_parent" android:layout_height="wrap_content"
+ android:layout_weight="0" android:paddingBottom="4dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/saves_state"/>
- <EditText android:id="@+id/saved"
- android:layout_width="match_parent" android:layout_height="wrap_content"
- android:layout_weight="1"
- android:background="@drawable/green"
- android:text="@string/initial_text"
- android:freezesText="true">
- <requestFocus />
- </EditText>
+ <EditText android:id="@+id/saved"
+ android:layout_width="match_parent" android:layout_height="wrap_content"
+ android:layout_weight="1" android:background="@drawable/green"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/initial_text"
+ android:freezesText="true">
+ </EditText>
- <TextView
- android:layout_width="match_parent" android:layout_height="wrap_content"
- android:layout_weight="0"
- android:paddingTop="8dip"
- android:paddingBottom="4dip"
- android:text="@string/no_saves_state"/>
+ <TextView
+ android:layout_width="match_parent" android:layout_height="wrap_content"
+ android:layout_weight="0" android:paddingTop="8dip" android:paddingBottom="4dip"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/no_saves_state"/>
- <EditText
- android:layout_width="match_parent" android:layout_height="wrap_content"
- android:layout_weight="1"
- android:background="@drawable/red"
- android:text="@string/initial_text">
- </EditText>
+ <EditText
+ android:layout_width="match_parent" android:layout_height="wrap_content"
+ android:layout_weight="1" android:background="@drawable/red"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="@string/initial_text">
+ </EditText>
-</LinearLayout>
-
+ </LinearLayout>
+</ScrollView>
diff --git a/samples/ApiDemos/res/values-v13/bools.xml b/samples/ApiDemos/res/values-v13/bools.xml
new file mode 100644
index 0000000..1b8909f
--- /dev/null
+++ b/samples/ApiDemos/res/values-v13/bools.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<resources>
+ <!-- True if running under Ice Cream Sandwich or later. -->
+ <bool name="atLeastIceCreamSandwich">true</bool>
+</resources>
diff --git a/samples/ApiDemos/res/values/bools.xml b/samples/ApiDemos/res/values/bools.xml
index 0faffb3..cf85197 100644
--- a/samples/ApiDemos/res/values/bools.xml
+++ b/samples/ApiDemos/res/values/bools.xml
@@ -19,4 +19,8 @@
API level. The default value is false; an alternative value
for Honeycomb is true. -->
<bool name="atLeastHoneycomb">false</bool>
+ <!-- This resource is true if running under at least Ice Cream Sandwich's
+ API level. The default value is false; an alternative value
+ for Ice Cream Sandwich is true. -->
+ <bool name="atLeastIceCreamSandwich">false</bool>
</resources>
diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml
index d86b194..d7858f0 100644
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -134,8 +134,6 @@
<string name="fragment_list_array">App/Fragment/List Array</string>
- <string name="fragment_list_cursor_loader">App/Fragment/List Cursor Loader</string>
-
<string name="fragment_menu">App/Fragment/Menu</string>
<string name="fragment_menu_msg">Build menus from two fragments, allowing
you to hide them to remove them..</string>
@@ -168,8 +166,6 @@
<string name="fragment_list_array_support">Support/App/Fragment/List Array</string>
- <string name="fragment_list_cursor_loader_support">Support/App/Fragment/List Cursor Loader</string>
-
<string name="fragment_menu_support">Support/App/Fragment/Menu</string>
<string name="fragment_retain_instance_support">Support/App/Fragment/Retain Instance</string>
@@ -178,7 +174,15 @@
<string name="fragment_stack_support">Support/App/Fragment/Stack</string>
+ <string name="fragment_pager_support">Support/App/Fragment/Pager</string>
+
+ <string name="loader_cursor">App/Loader/Cursor</string>
+
+ <string name="loader_custom">App/Loader/Custom</string>
+
<string name="loader_throttle">App/Loader/Throttle</string>
+
+ <string name="loader_cursor_support">Support/App/Loader/Cursor</string>
<string name="loader_throttle_support">Support/Loader/Throttle</string>
@@ -348,13 +352,17 @@
<string name="styled_text">Plain, <b>bold</b>, <i>italic</i>, <b><i>bold-italic</i></b></string>
<string name="styled_text_prog">Assigned programmatically:</string>
+ <string name="activity_resources_width_and_height">Content/Resources/Width and Height</string>
+ <string name="resources_width_and_height_description">The layouts below use -wNNNdp and
+ -hNNNdp to select between different versions based on the size of the screen.</string>
+
<string name="activity_read_asset">Content/Assets/Read Asset</string>
<string name="activity_themes">Content/Resources/Themes</string>
<string name="activity_resources">Content/Resources/Resources</string>
<string name="activity_pick_contact">Content/Provider/Pick Contact</string>
- <string name="pick_contact_msg">Invoke Contacts to pick varius kinds of
+ <string name="pick_contact_msg">Invoke Contacts to pick various kinds of
contact data. None of these require that the caller hold the
READ_CONTACTS permission.</string>
<string name="pick_contact">Pick a Contact</string>
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/FragmentListCursorLoader.java b/samples/ApiDemos/src/com/example/android/apis/app/LoaderCursor.java
similarity index 95%
rename from samples/ApiDemos/src/com/example/android/apis/app/FragmentListCursorLoader.java
rename to samples/ApiDemos/src/com/example/android/apis/app/LoaderCursor.java
index 57604f0..a8ac0d4 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/FragmentListCursorLoader.java
+++ b/samples/ApiDemos/src/com/example/android/apis/app/LoaderCursor.java
@@ -38,17 +38,17 @@
import android.widget.SearchView.OnQueryTextListener;
/**
- * Demonstration of more complex use if a ListFragment, including showing
- * an empty view and loading progress.
+ * Demonstration of the use of a CursorLoader to load and display contacts
+ * data in a fragment.
*/
-public class FragmentListCursorLoader extends Activity {
+public class LoaderCursor extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FragmentManager fm = getFragmentManager();
-
+
// Create the list fragment and add it as our sole content.
if (fm.findFragmentById(android.R.id.content) == null) {
CursorLoaderListFragment list = new CursorLoaderListFragment();
@@ -82,7 +82,10 @@
new String[] { Contacts.DISPLAY_NAME, Contacts.CONTACT_STATUS },
new int[] { android.R.id.text1, android.R.id.text2 }, 0);
setListAdapter(mAdapter);
-
+
+ // Start out with a progress indicator.
+ setListShown(false);
+
// Prepare the loader. Either re-connect with an existing one,
// or start a new one.
getLoaderManager().initLoader(0, null, this);
@@ -111,7 +114,7 @@
// Don't care about this.
return true;
}
-
+
@Override public void onListItemClick(ListView l, View v, int position, long id) {
// Insert desired behavior here.
Log.i("FragmentComplexList", "Item clicked: " + id);
@@ -154,6 +157,9 @@
// Swap the new cursor in. (The framework will take care of closing the
// old cursor once we return.)
mAdapter.swapCursor(data);
+
+ // The list should now be shown.
+ setListShown(true);
}
public void onLoaderReset(Loader<Cursor> loader) {
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/LoaderCustom.java b/samples/ApiDemos/src/com/example/android/apis/app/LoaderCustom.java
new file mode 100644
index 0000000..883ab14
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/app/LoaderCustom.java
@@ -0,0 +1,478 @@
+/*
+ * 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.app;
+
+import com.example.android.apis.R;
+
+import java.io.File;
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import android.app.Activity;
+import android.app.FragmentManager;
+import android.app.ListFragment;
+import android.app.LoaderManager;
+import android.content.AsyncTaskLoader;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.Loader;
+import android.content.pm.ActivityInfo;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.SearchView;
+import android.widget.TextView;
+import android.widget.SearchView.OnQueryTextListener;
+
+/**
+ * Demonstration of the implementation of a custom Loader.
+ */
+public class LoaderCustom extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ FragmentManager fm = getFragmentManager();
+
+ // Create the list fragment and add it as our sole content.
+ if (fm.findFragmentById(android.R.id.content) == null) {
+ AppListFragment list = new AppListFragment();
+ fm.beginTransaction().add(android.R.id.content, list).commit();
+ }
+ }
+
+//BEGIN_INCLUDE(loader)
+ /**
+ * This class holds the per-item data in our Loader.
+ */
+ public static class AppEntry {
+ public AppEntry(AppListLoader loader, ApplicationInfo info) {
+ mLoader = loader;
+ mInfo = info;
+ mApkFile = new File(info.sourceDir);
+ }
+
+ public ApplicationInfo getApplicationInfo() {
+ return mInfo;
+ }
+
+ public String getLabel() {
+ return mLabel;
+ }
+
+ public Drawable getIcon() {
+ if (mIcon == null) {
+ if (mApkFile.exists()) {
+ mIcon = mInfo.loadIcon(mLoader.mPm);
+ return mIcon;
+ } else {
+ mMounted = false;
+ }
+ } else if (!mMounted) {
+ // If the app wasn't mounted but is now mounted, reload
+ // its icon.
+ if (mApkFile.exists()) {
+ mMounted = true;
+ mIcon = mInfo.loadIcon(mLoader.mPm);
+ return mIcon;
+ }
+ } else {
+ return mIcon;
+ }
+
+ return mLoader.getContext().getResources().getDrawable(
+ android.R.drawable.sym_def_app_icon);
+ }
+
+ @Override public String toString() {
+ return mLabel;
+ }
+
+ void loadLabel(Context context) {
+ if (mLabel == null || !mMounted) {
+ if (!mApkFile.exists()) {
+ mMounted = false;
+ mLabel = mInfo.packageName;
+ } else {
+ mMounted = true;
+ CharSequence label = mInfo.loadLabel(context.getPackageManager());
+ mLabel = label != null ? label.toString() : mInfo.packageName;
+ }
+ }
+ }
+
+ private final AppListLoader mLoader;
+ private final ApplicationInfo mInfo;
+ private final File mApkFile;
+ private String mLabel;
+ private Drawable mIcon;
+ private boolean mMounted;
+ }
+
+ /**
+ * Perform alphabetical comparison of application entry objects.
+ */
+ public static final Comparator<AppEntry> ALPHA_COMPARATOR = new Comparator<AppEntry>() {
+ private final Collator sCollator = Collator.getInstance();
+ @Override
+ public int compare(AppEntry object1, AppEntry object2) {
+ return sCollator.compare(object1.getLabel(), object2.getLabel());
+ }
+ };
+
+ /**
+ * Helper for determining if the configuration has changed in an interesting
+ * way so we need to rebuild the app list.
+ */
+ public static class InterestingConfigChanges {
+ final Configuration mLastConfiguration = new Configuration();
+ int mLastDensity;
+
+ boolean applyNewConfig(Resources res) {
+ int configChanges = mLastConfiguration.updateFrom(res.getConfiguration());
+ boolean densityChanged = mLastDensity != res.getDisplayMetrics().densityDpi;
+ if (densityChanged || (configChanges&(ActivityInfo.CONFIG_LOCALE
+ |ActivityInfo.CONFIG_UI_MODE|ActivityInfo.CONFIG_SCREEN_LAYOUT)) != 0) {
+ mLastDensity = res.getDisplayMetrics().densityDpi;
+ return true;
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Helper class to look for interesting changes to the installed apps
+ * so that the loader can be updated.
+ */
+ public static class PackageIntentReceiver extends BroadcastReceiver {
+ final AppListLoader mLoader;
+
+ public PackageIntentReceiver(AppListLoader loader) {
+ mLoader = loader;
+ IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
+ filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
+ filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
+ filter.addDataScheme("package");
+ mLoader.getContext().registerReceiver(this, filter);
+ // Register for events related to sdcard installation.
+ IntentFilter sdFilter = new IntentFilter();
+ sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
+ sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
+ mLoader.getContext().registerReceiver(this, sdFilter);
+ }
+
+ @Override public void onReceive(Context context, Intent intent) {
+ // Tell the loader about the change.
+ mLoader.onContentChanged();
+ }
+ }
+
+ /**
+ * A custom Loader that loads all of the installed applications.
+ */
+ public static class AppListLoader extends AsyncTaskLoader<List<AppEntry>> {
+ final InterestingConfigChanges mLastConfig = new InterestingConfigChanges();
+ final PackageManager mPm;
+
+ List<AppEntry> mApps;
+ PackageIntentReceiver mPackageObserver;
+
+ public AppListLoader(Context context) {
+ super(context);
+
+ // Retrieve the package manager for later use; note we don't
+ // use 'context' directly but instead the save global application
+ // context returned by getContext().
+ mPm = getContext().getPackageManager();
+ }
+
+ /**
+ * This is where the bulk of our work is done. This function is
+ * called in a background thread and should generate a new set of
+ * data to be published by the loader.
+ */
+ @Override public List<AppEntry> loadInBackground() {
+ // Retrieve all known applications.
+ List<ApplicationInfo> apps = mPm.getInstalledApplications(
+ PackageManager.GET_UNINSTALLED_PACKAGES |
+ PackageManager.GET_DISABLED_COMPONENTS);
+ if (apps == null) {
+ apps = new ArrayList<ApplicationInfo>();
+ }
+
+ final Context context = getContext();
+
+ // Create corresponding array of entries and load their labels.
+ List<AppEntry> entries = new ArrayList<AppEntry>(apps.size());
+ for (int i=0; i<apps.size(); i++) {
+ AppEntry entry = new AppEntry(this, apps.get(i));
+ entry.loadLabel(context);
+ entries.add(entry);
+ }
+
+ // Sort the list.
+ Collections.sort(entries, ALPHA_COMPARATOR);
+
+ // Done!
+ return entries;
+ }
+
+ /**
+ * Called when there is new data to deliver to the client. The
+ * super class will take care of delivering it; the implementation
+ * here just adds a little more logic.
+ */
+ @Override public void deliverResult(List<AppEntry> apps) {
+ if (isReset()) {
+ // An async query came in while the loader is stopped. We
+ // don't need the result.
+ if (apps != null) {
+ onReleaseResources(apps);
+ }
+ }
+ List<AppEntry> oldApps = apps;
+ mApps = apps;
+
+ if (isStarted()) {
+ // If the Loader is currently started, we can immediately
+ // deliver its results.
+ super.deliverResult(apps);
+ }
+
+ // At this point we can release the resources associated with
+ // 'oldApps' if needed; now that the new result is delivered we
+ // know that it is no longer in use.
+ if (oldApps != null) {
+ onReleaseResources(oldApps);
+ }
+ }
+
+ /**
+ * Handles a request to start the Loader.
+ */
+ @Override protected void onStartLoading() {
+ if (mApps != null) {
+ // If we currently have a result available, deliver it
+ // immediately.
+ deliverResult(mApps);
+ }
+
+ // Start watching for changes in the app data.
+ if (mPackageObserver == null) {
+ mPackageObserver = new PackageIntentReceiver(this);
+ }
+
+ // Has something interesting in the configuration changed since we
+ // last built the app list?
+ boolean configChange = mLastConfig.applyNewConfig(getContext().getResources());
+
+ if (takeContentChanged() || mApps == null || configChange) {
+ // If the data has changed since the last time it was loaded
+ // or is not currently available, start a load.
+ forceLoad();
+ }
+ }
+
+ /**
+ * Handles a request to stop the Loader.
+ */
+ @Override protected void onStopLoading() {
+ // Attempt to cancel the current load task if possible.
+ cancelLoad();
+ }
+
+ /**
+ * Handles a request to cancel a load.
+ */
+ @Override public void onCanceled(List<AppEntry> apps) {
+ super.onCanceled(apps);
+
+ // At this point we can release the resources associated with 'apps'
+ // if needed.
+ onReleaseResources(apps);
+ }
+
+ /**
+ * Handles a request to completely reset the Loader.
+ */
+ @Override protected void onReset() {
+ super.onReset();
+
+ // Ensure the loader is stopped
+ onStopLoading();
+
+ // At this point we can release the resources associated with 'apps'
+ // if needed.
+ if (mApps != null) {
+ onReleaseResources(mApps);
+ mApps = null;
+ }
+
+ // Stop monitoring for changes.
+ if (mPackageObserver != null) {
+ getContext().unregisterReceiver(mPackageObserver);
+ mPackageObserver = null;
+ }
+ }
+
+ /**
+ * Helper function to take care of releasing resources associated
+ * with an actively loaded data set.
+ */
+ protected void onReleaseResources(List<AppEntry> apps) {
+ // For a simple List<> there is nothing to do. For something
+ // like a Cursor, we would close it here.
+ }
+ }
+//END_INCLUDE(loader)
+
+//BEGIN_INCLUDE(fragment)
+ public static class AppListAdapter extends ArrayAdapter<AppEntry> {
+ private final LayoutInflater mInflater;
+
+ public AppListAdapter(Context context) {
+ super(context, android.R.layout.simple_list_item_2);
+ mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ }
+
+ public void setData(List<AppEntry> data) {
+ clear();
+ if (data != null) {
+ addAll(data);
+ }
+ }
+
+ /**
+ * Populate new items in the list.
+ */
+ @Override public View getView(int position, View convertView, ViewGroup parent) {
+ View view;
+
+ if (convertView == null) {
+ view = mInflater.inflate(R.layout.list_item_icon_text, parent, false);
+ } else {
+ view = convertView;
+ }
+
+ AppEntry item = getItem(position);
+ ((ImageView)view.findViewById(R.id.icon)).setImageDrawable(item.getIcon());
+ ((TextView)view.findViewById(R.id.text)).setText(item.getLabel());
+
+ return view;
+ }
+ }
+
+ public static class AppListFragment extends ListFragment
+ implements OnQueryTextListener, LoaderManager.LoaderCallbacks<List<AppEntry>> {
+
+ // This is the Adapter being used to display the list's data.
+ AppListAdapter mAdapter;
+
+ // If non-null, this is the current filter the user has provided.
+ String mCurFilter;
+
+ @Override public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ // Give some text to display if there is no data. In a real
+ // application this would come from a resource.
+ setEmptyText("No applications");
+
+ // We have a menu item to show in action bar.
+ setHasOptionsMenu(true);
+
+ // Create an empty adapter we will use to display the loaded data.
+ mAdapter = new AppListAdapter(getActivity());
+ setListAdapter(mAdapter);
+
+ // Start out with a progress indicator.
+ setListShown(false);
+
+ // Prepare the loader. Either re-connect with an existing one,
+ // or start a new one.
+ getLoaderManager().initLoader(0, null, this);
+ }
+
+ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ // Place an action bar item for searching.
+ MenuItem item = menu.add("Search");
+ item.setIcon(android.R.drawable.ic_menu_search);
+ item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ SearchView sv = new SearchView(getActivity());
+ sv.setOnQueryTextListener(this);
+ item.setActionView(sv);
+ }
+
+ @Override public boolean onQueryTextChange(String newText) {
+ // Called when the action bar search text has changed. Since this
+ // is a simple array adapter, we can just have it do the filtering.
+ mCurFilter = !TextUtils.isEmpty(newText) ? newText : null;
+ mAdapter.getFilter().filter(mCurFilter);
+ return true;
+ }
+
+ @Override public boolean onQueryTextSubmit(String query) {
+ // Don't care about this.
+ return true;
+ }
+
+ @Override public void onListItemClick(ListView l, View v, int position, long id) {
+ // Insert desired behavior here.
+ Log.i("LoaderCustom", "Item clicked: " + id);
+ }
+
+ @Override public Loader<List<AppEntry>> onCreateLoader(int id, Bundle args) {
+ // This is called when a new Loader needs to be created. This
+ // sample only has one Loader with no arguments, so it is simple.
+ return new AppListLoader(getActivity());
+ }
+
+ @Override public void onLoadFinished(Loader<List<AppEntry>> loader, List<AppEntry> data) {
+ // Set the new data in the adapter.
+ mAdapter.setData(data);
+
+ // The list should now be shown.
+ setListShown(true);
+ }
+
+ @Override public void onLoaderReset(Loader<List<AppEntry>> loader) {
+ // Clear the data in the adapter.
+ mAdapter.setData(null);
+ }
+ }
+//END_INCLUDE(fragment)
+}
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/_index.html b/samples/ApiDemos/src/com/example/android/apis/app/_index.html
index fa69dee..71ccb54 100644
--- a/samples/ApiDemos/src/com/example/android/apis/app/_index.html
+++ b/samples/ApiDemos/src/com/example/android/apis/app/_index.html
@@ -119,10 +119,6 @@
<dt><a href="FragmentListArray.html">Fragment List Array</a></dt>
<dd>Demonstrates use of ListFragment to show the contents of a simple ArrayAdapter.</dd>
- <dt><a href="FragmentListCursorLoader.html">Fragment List Cursor Loader</a></dt>
- <dd>Demonstrates use of LoaderManager to perform a query for a Cursor that
- populates a ListFragment.</dd>
-
<dt><a href="FragmentMenu.html">Fragment Menu</a></dt>
<dd>Demonstrates populating custom menu items from a Fragment.</dd>
@@ -162,6 +158,10 @@
<h3 id="LoaderManager">LoaderManager</h3>
<dl>
+ <dt><a href="LoaderCursor.html">Loader Cursor</a></dt>
+ <dd>Demonstrates use of LoaderManager to perform a query for a Cursor that
+ populates a ListFragment.</dd>
+
<dt><a href="LoaderThrottle.html">Loader Throttle</a></dt>
<dd>Complete end-to-end demonstration of a simple content provider that
populates data in a list through a cursor loader. The UI allows the list
diff --git a/samples/ApiDemos/src/com/example/android/apis/content/ResourcesWidthAndHeight.java b/samples/ApiDemos/src/com/example/android/apis/content/ResourcesWidthAndHeight.java
new file mode 100644
index 0000000..6c64e95
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/content/ResourcesWidthAndHeight.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2011 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.content;
+
+import com.example.android.apis.R;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.widget.TextView;
+
+public class ResourcesWidthAndHeight extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // This layout uses different configurations to adjust
+ // what is shown based on the current screen width and height.
+ setContentView(R.layout.resources_width_and_height);
+ }
+}
diff --git a/samples/ApiDemos/src/com/example/android/apis/support/app/FragmentPagerSupport.java b/samples/ApiDemos/src/com/example/android/apis/support/app/FragmentPagerSupport.java
new file mode 100644
index 0000000..46d29ac
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/support/app/FragmentPagerSupport.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2011 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.support.app;
+
+import com.example.android.apis.R;
+import com.example.android.apis.Shakespeare;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentPager;
+import android.support.v4.app.FragmentTransaction;
+import android.support.v4.app.ListFragment;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.View.OnClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.TextView;
+
+public class FragmentPagerSupport extends FragmentActivity
+ implements FragmentPager.Adapter {
+ static final int NUM_ITEMS = 10;
+
+ FragmentPager mPager;
+ int mCurPos;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.fragment_pager);
+
+ mPager = (FragmentPager)findViewById(R.id.pager);
+ mPager.setAdapter(this);
+
+ // Watch for button clicks.
+ Button button = (Button)findViewById(R.id.new_fragment);
+ button.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ mCurPos++;
+ if (mCurPos < NUM_ITEMS) {
+ mPager.setCurrentItem(mCurPos);
+ } else {
+ mCurPos--;
+ }
+ }
+ });
+ }
+
+ @Override
+ public int getCount() {
+ return NUM_ITEMS;
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+ return ArrayListFragment.newInstance(position);
+ }
+
+ public static class ArrayListFragment extends ListFragment {
+ int mNum;
+
+ /**
+ * Create a new instance of CountingFragment, providing "num"
+ * as an argument.
+ */
+ static ArrayListFragment newInstance(int num) {
+ ArrayListFragment f = new ArrayListFragment();
+
+ // Supply num input as an argument.
+ Bundle args = new Bundle();
+ args.putInt("num", num);
+ f.setArguments(args);
+
+ return f;
+ }
+
+ /**
+ * When creating, retrieve this instance's number from its arguments.
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mNum = getArguments() != null ? getArguments().getInt("num") : 1;
+ }
+
+ /**
+ * The Fragment's UI is just a simple text view showing its
+ * instance number.
+ */
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View v = inflater.inflate(R.layout.fragment_pager_list, container, false);
+ View tv = v.findViewById(R.id.text);
+ ((TextView)tv).setText("Fragment #" + mNum);
+ return v;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ setListAdapter(new ArrayAdapter<String>(getActivity(),
+ android.R.layout.simple_list_item_1, Shakespeare.TITLES));
+ }
+
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ Log.i("FragmentList", "Item clicked: " + id);
+ }
+ }
+}
diff --git a/samples/ApiDemos/src/com/example/android/apis/support/app/FragmentListCursorLoaderSupport.java b/samples/ApiDemos/src/com/example/android/apis/support/app/LoaderCursorSupport.java
similarity index 96%
rename from samples/ApiDemos/src/com/example/android/apis/support/app/FragmentListCursorLoaderSupport.java
rename to samples/ApiDemos/src/com/example/android/apis/support/app/LoaderCursorSupport.java
index 98aa47f..491ae0e 100644
--- a/samples/ApiDemos/src/com/example/android/apis/support/app/FragmentListCursorLoaderSupport.java
+++ b/samples/ApiDemos/src/com/example/android/apis/support/app/LoaderCursorSupport.java
@@ -37,10 +37,10 @@
import android.widget.ListView;
/**
- * Demonstration of more complex use if a ListFragment, including showing
- * an empty view and loading progress.
+ * Demonstration of the use of a CursorLoader to load and display contacts
+ * data in a fragment.
*/
-public class FragmentListCursorLoaderSupport extends FragmentActivity {
+public class LoaderCursorSupport extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {