<meta-data android:name="string" android:resource="resource specification" android:value="string" />
- contained in:
- A name-value pair for an item of additional, arbitrary data that can
be supplied to the parent component. A component element can contain any
<meta-data>subelements. The values from all of them are collected in a single
Bundleobject and made available to the component as the
Ordinary values are specified through the
valueattribute. However, to assign a resource ID as the value, use the
resourceattribute instead. For example, the following code assigns whatever value is stored in the
@string/kangarooresource to the "
<meta-data android:name="zoo" android:value="@string/kangaroo" />
On the other hand, using the
resourceattribute would assign "
zoo" the numeric ID of the resource, not the value stored in the resource:
<meta-data android:name="zoo" android:resource="@string/kangaroo" />
It is highly recommended that you avoid supplying related data as multiple separate
<meta-data>entries. Instead, if you have complex data to associate with a component, store it as a resource and use the
resourceattribute to inform the component of its ID.
- A unique name for the item. To ensure that the name is unique, use a
Java-style naming convention — for example,
- A reference to a resource. The ID of the resource is the value assigned
to the item. The ID can be retrieved from the meta-data Bundle by the
- The value assigned to the item. The data types that can be assigned as values and the Bundle methods that components use to retrieve those values are listed in the following table:
Type Bundle method String value, using double backslashes (
\\) to escape characters — such as "
\\n" and "
\\uxxxxx" for a Unicode character.
Integer value, such as "
Boolean value, either "
true" or "
Color value, in the form "
#rrggbb", or "
Float value, such as "
- introduced in:
- API Level 1