diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml index 10313fb10..a588418b1 100644 --- a/samples/ApiDemos/AndroidManifest.xml +++ b/samples/ApiDemos/AndroidManifest.xml @@ -36,7 +36,7 @@ - + @@ -907,6 +907,15 @@ + + + + + + + + diff --git a/samples/ApiDemos/res/layout/resources_layout_reference.xml b/samples/ApiDemos/res/layout/resources_layout_reference.xml new file mode 100644 index 000000000..2d41143a4 --- /dev/null +++ b/samples/ApiDemos/res/layout/resources_layout_reference.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + diff --git a/samples/ApiDemos/res/layout/resources_layout_reference_tablet.xml b/samples/ApiDemos/res/layout/resources_layout_reference_tablet.xml new file mode 100644 index 000000000..a2cf17aae --- /dev/null +++ b/samples/ApiDemos/res/layout/resources_layout_reference_tablet.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + diff --git a/samples/ApiDemos/res/values-sw600dp/layout.xml b/samples/ApiDemos/res/values-sw600dp/layout.xml new file mode 100644 index 000000000..1f9771f24 --- /dev/null +++ b/samples/ApiDemos/res/values-sw600dp/layout.xml @@ -0,0 +1,22 @@ + + + + + + + @layout/resources_layout_reference_tablet + diff --git a/samples/ApiDemos/res/values-xlarge/layout.xml b/samples/ApiDemos/res/values-xlarge/layout.xml new file mode 100644 index 000000000..1f9771f24 --- /dev/null +++ b/samples/ApiDemos/res/values-xlarge/layout.xml @@ -0,0 +1,22 @@ + + + + + + + @layout/resources_layout_reference_tablet + diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml index da70d283c..8950bb75d 100644 --- a/samples/ApiDemos/res/values/strings.xml +++ b/samples/ApiDemos/res/values/strings.xml @@ -327,6 +327,13 @@ Plain, bold, italic, bold-italic Assigned programmatically: + Content/Resources/Layout Reference + 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. + Default layout + Tablet layout + Content/Resources/Width and Height The layouts below use -wNNNdp and -hNNNdp to select between different versions based on the size of the screen. diff --git a/samples/ApiDemos/src/com/example/android/apis/content/ResourcesLayoutReference.java b/samples/ApiDemos/src/com/example/android/apis/content/ResourcesLayoutReference.java new file mode 100644 index 000000000..0682bcb3d --- /dev/null +++ b/samples/ApiDemos/src/com/example/android/apis/content/ResourcesLayoutReference.java @@ -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); + } +} diff --git a/samples/ApiDemos/src/com/example/android/apis/content/_index.html b/samples/ApiDemos/src/com/example/android/apis/content/_index.html index fc484a926..f49b8d92e 100644 --- a/samples/ApiDemos/src/com/example/android/apis/content/_index.html +++ b/samples/ApiDemos/src/com/example/android/apis/content/_index.html @@ -8,4 +8,17 @@
Resources
Demonstrates loading styled strings from a resource file, and extracting the raw text.
+ +
Resources Layout Reference
+
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.
+ +
Resources Smallest Width
+
Shows how you can vary a layout resource based on the device's smallest + width configuration
+ +
Resources Width and Height
+
Shows how you can vary a layout resource based on the device's current + width dp and height dp configurations.