@, @ Android: type, @ *, and ,@*,? , @ + Meaning and Difference

Source: Internet
Author: User

I. @ indicates referencing Resources

1. Reference custom resources. Format: @ [Package:] type/Name

Android: text = "@ string/hello"

 

2. reference system resources. Format: @ Android: type/Name

Android: textcolor = "@ Android: color/opaque_red"

Note: In fact@ Android: type/name is a subclass of @ [Package:] type/Name

2. @ * indicates that the system's non-public resources are referenced. Format: @ * Android: type/Name

System resource definition is divided into public and non-public. The public statement is as follows:

<Sdk_path> \ platforms \ Android-8 \ data \ res \ values \ public. xml

@ * Android: type/Name:All resources defined by the system can be called.

@ Android: type/Name:Only resources with the publi attribute can be called.

Note: resources not declared in public. XML are not recommended by Google.

3 .? Reference topic attributes

Another resource value allows you to reference the attribute values in the current topic. This attribute value can only be used in style resources and XML attributes. It allows you to change the appearance of the UI element by changing them to the standard changes provided by the current topic, rather than providing specific values. For example:

Android: textcolor = "? Android: textdisabledcolor"

Note that this is very similar to resource reference, except that we use "? "Prefix replaces "@". When you use this tag, you provide the name of the property resource, which will be searched in the topic, so you do not need to display the Declaration type (if the Declaration, the form is? Android: ATTR/Android: textdisabledcolor ). Besides using the resource identifier to query the value in the topic instead of the original resource, the naming syntax is the same as that in the "@" Format :? [Namespace:] type/name. The type is optional.

Thu. @ + Indicates creating or referencing a resource. Format: @ + type/Name

Meaning: "+" indicates adding a record to the internal class named type in R. java. For example, "@ + ID/button" means to add a constant named "button" to the static internal class "ID" in the R. Java file. The constant is the identifier of the resource. If the identifier (including system resources) already exists, the identifier is referenced. The most common method is to define the resource ID, for example:

@ + ID/resource ID name create a resource ID

@ ID/resource ID name the application's existing defined resource ID, including the System ID

@ Android: ID/resource ID refers to the System ID, which is equivalent to @ ID/resource ID

 

Android: Id = "@ + ID/selectdlg"

Android: Id = "@ Android: ID/text1"

Android: Id = "@ ID/button3"
URL:Http://greatverve.cnblogs.com/archive/2011/12/27/Android-xml.html

Related Article

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.