New API demo showing how to make a resource reference.
Change-Id: I450d70432debc9d7f58a7f6597628dacc0225ddd
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
<!-- For android.media.audiofx.Visualizer -->
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
|
||||
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="3" />
|
||||
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="13" />
|
||||
|
||||
<!-- We will request access to the camera, saying we require a camera
|
||||
of some sort but not one with autofocus capability. -->
|
||||
@@ -907,6 +907,15 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".content.ResourcesLayoutReference"
|
||||
android:label="@string/activity_resources_layout_reference">
|
||||
<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.ResourcesWidthAndHeight"
|
||||
android:label="@string/activity_resources_width_and_height"
|
||||
android:enabled="@bool/atLeastHoneycombMR2">
|
||||
|
||||
35
samples/ApiDemos/res/layout/resources_layout_reference.xml
Normal file
35
samples/ApiDemos/res/layout/resources_layout_reference.xml
Normal file
@@ -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_layout_reference_description"/>
|
||||
|
||||
<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/textAppearanceLarge"
|
||||
android:text="@string/resources_layout_reference_default"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -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_layout_reference_description"/>
|
||||
|
||||
<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/textAppearanceLarge"
|
||||
android:text="@string/resources_layout_reference_tablet"/>
|
||||
|
||||
</LinearLayout>
|
||||
22
samples/ApiDemos/res/values-sw600dp/layout.xml
Normal file
22
samples/ApiDemos/res/values-sw600dp/layout.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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>
|
||||
<!-- Define a new configuration for the resources_layout_reference layout,
|
||||
which uses the special tablet layout. -->
|
||||
<item type="layout" name="resources_layout_reference">
|
||||
@layout/resources_layout_reference_tablet</item>
|
||||
</resources>
|
||||
22
samples/ApiDemos/res/values-xlarge/layout.xml
Normal file
22
samples/ApiDemos/res/values-xlarge/layout.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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>
|
||||
<!-- Define a new configuration for the resources_layout_reference layout,
|
||||
which uses the special tablet layout. -->
|
||||
<item type="layout" name="resources_layout_reference">
|
||||
@layout/resources_layout_reference_tablet</item>
|
||||
</resources>
|
||||
@@ -327,6 +327,13 @@
|
||||
<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_layout_reference">Content/Resources/Layout Reference</string>
|
||||
<string name="resources_layout_reference_description">Shows how to write layout
|
||||
resource references, so that you can define multiple different configurations of
|
||||
a layout resource that refer to one actual XML definition.</string>
|
||||
<string name="resources_layout_reference_default">Default layout</string>
|
||||
<string name="resources_layout_reference_tablet">Tablet layout</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>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class ResourcesLayoutReference extends Activity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// This layout uses different configurations to adjust
|
||||
// what is shown based on the smallest width that will occur.
|
||||
setContentView(R.layout.resources_layout_reference);
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,17 @@
|
||||
|
||||
<dt><a href="ResourcesSample.html">Resources</a></dt>
|
||||
<dd>Demonstrates loading styled strings from a resource file, and extracting the raw text. </dd>
|
||||
|
||||
<dt><a href="ResourcesLayoutReference.html">Resources Layout Reference</a></dt>
|
||||
<dd>Shows how to make references between resources; this examples shows how this
|
||||
can be used to define multiple configurations for a layout resource that
|
||||
reference the same layout XML.</dd>
|
||||
|
||||
<dt><a href="ResourcesSmallestWidth.html">Resources Smallest Width</a></dt>
|
||||
<dd>Shows how you can vary a layout resource based on the device's smallest
|
||||
width configuration</dd>
|
||||
|
||||
<dt><a href="ResourcesWidthAndHeight.html">Resources Width and Height</a></dt>
|
||||
<dd>Shows how you can vary a layout resource based on the device's current
|
||||
width dp and height dp configurations.</dd>
|
||||
</dl>
|
||||
|
||||
Reference in New Issue
Block a user