Androidmanifest. xml file (meta-data)

Source: Internet
Author: User

Syntax (syntax ):

<Meta-dataandroid: Name ="String"
Android: Resource ="Resource
Specification
"
Android: value ="String"/>

Included in (contained in ):

<Activity>

<Activity-alias>

<Service>

<Cycler>

Description ):

This element uses the name-Value Pair format to provide any optional data to its parent component. A component element can contain any number of <meta-data> sub-elements. All the values defined in these elements are collected into a bundle object and provided to the packageiteminfo of the component. metadata attribute field.

The value is usually specified through its value attribute. However, you can also use the resource attribute to associate a resource ID with a value.

For example, the following code associates the value stored in the @ string/kangaroo resource with the "Zoo" Name:

<Meta-data
Android: Name = "Zoo"
Android: value = "@ string/Kangaroo"
/>

In addition, the resource attribute is used to allocate a digital resource ID to zoo, instead of the value stored in the resource. For example:

<Meta-data
Android: Name = "Zoo"
Android: Resource = "@ string/Kangaroo"
/>

Avoid using multiple independent <meta-data> entities to provide relevant data. On the contrary, if complex data needs to be associated with components, the data is saved as resources, and the resource attribute is used to notify related resource IDs to components.

Attributes (attributes ):

Android: Name

A unique name for the project. The naming rules of Java styles can ensure the uniqueness of names, for example:

Com. example. Project. activity. Fred.

Android: Resource

This attribute defines a resource to be referenced. The resource ID will be associated with this project. The bundle. getint () method can be used to obtain this ID from the bundle object of meta-data.

Android: Value

This property will assign a value to the project. The following table lists the data types that may be allocated and how to obtain the data:

Type

Bundle object Method

String. For a Unicode character, the double slash (\) is used for escape, such as \ n and \ uxxxx.

Getstring ()

Integer, such as 100

Getint ()

Boolean value, true or false

Getboolean ()

Color values, such as # RGB, # argb, # rrggbb, and # aarrggbb

Getstring ()

Floating point value, such as 1.23

Getfloat ()

Introduced version (introduced in ):

API Level 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.