From 528954c4d63980c0515528624130477f921cbc60 Mon Sep 17 00:00:00 2001
From: Scott Main
<ViewGroupClass xmlns:android="http://schemas.android.com/apk/res/android" - id="@+id/string_name" (attributes)> + android:id="@+id/string_name" (attributes)> <widget or other nested ViewGroupClass>+ <requestFocus/>(0 or 1 per layout file, assigned to any element) </ViewGroupClass> @@ -919,7 +919,7 @@ res/layout/some_file.xml.
The file must have a single root element. This can be a ViewGroup class that contains other elements, or a widget (or custom item) if it's only one object. By default, you can use any (case-sensitive) Android {@link android.widget widget} or {@link android.view.ViewGroup ViewGroup} class name as an element. These elements support attributes that apply to the underlying class, but the naming is not as clear. How to discover what attributes are supported for what tags is discussed below. You should not assume that any nesting is valid (for example you cannot enclose <TextView>
elements inside a <ListLayout>
).
If a class derives from another class, the XML element inherits all the attributes from the element that it "derives" from. So, for example, <EditText>
is the corresponding XML element for the EditText class. It exposes its own unique attributes (EditText_numeric
), as well as all attributes supported by <TextView>
and <View>
. For the id attribute of a tag in XML, you should use a special syntax: "@+id/somestringvalue". The "@+" syntax creates a resource number in the R.id class, if one doesn't exist, or uses it, if it does exist. When declaring an ID value for an XML tag, use this syntax. Example: <TextView id="@+id/nameTextbox"/>
, and refer to it this way in Java: findViewById(R.id.nameTextbox)
. All elements support the following values:
If a class derives from another class, the XML element inherits all the attributes from the element that it "derives" from. So, for example, <EditText>
is the corresponding XML element for the EditText class. It exposes its own unique attributes (EditText_numeric
), as well as all attributes supported by <TextView>
and <View>
. For the id attribute of a tag in XML, you should use a special syntax: "@+id/somestringvalue". The "@+" syntax creates a resource number in the R.id class, if one doesn't exist, or uses it, if it does exist. When declaring an ID value for an XML tag, use this syntax. Example: <TextView android:id="@+id/nameTextbox"/>
, and refer to it this way in Java: findViewById(R.id.nameTextbox)
. All elements support the following values:
<declare-styleable id=your_java_class_name>
. See res/layout/attrs.xml in ApiDemos.
+ res/values/attrs.xml - Defines the XML element, and the attributes that it supports, for clients to use to instantiate your object in their layout XML file. Define your element in a <declare-styleable name=your_java_class_name>
. See res/values/attrs.xml in ApiDemos.