Question mark about Android? And @ symbol usage

Source: Internet
Author: User

@ Indicates referencing a resource and declares that this is a resource reference-the subsequent text is the resource name provided in the form of @ [package:] type/name.
@ Android: string indicates the referenced system (android. *) resource.
@ String indicates referencing internal application resources
For id, you can use @ + id to create an id
? Reference Property
"?" Reference topic attributes. When you use this tag, the resource name you provide must be located in the topic attributes, because the resource tool considers this resource attribute to be expected, you do not need to explicitly specify its type (? Android: attr/android: textDisabledColor ).

Use 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.
As shown in the example, we use this feature in layout resources to set the text color to a standard color. These standard colors are defined in the basic system subject:

Java code
<? Xml version = "1.0" encoding = "UTF-8"?>
<EditText id = "text"
Xmlns: android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "fill_parent" android: layout_height = "fill_parent"
Android: textColor = "? Android: textDisabledColor"
Android: text = "@ string/hello_world"/>


Note that this is very similar to resource reference, except that we use a "?" The prefix replaces "@". When you use this tag, you provide the name of the property resource, which will be searched in the topic-because the resource tool knows the required property resource, therefore, you do not need to explicitly declare this type (if so, the form is? Android: attr/android: textDisabledColor ).
In addition to using the resource identifier to query the value in the topic instead of the original resource, here the name syntax for this type is :? [Namespace:] The form of typpe/name is the same as that of "@", which is also optional.

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.