Differences between @ + id and @ id in Android, and androidid @ id

Source: Internet
Author: User

Differences between @ + id and @ id in Android, and androidid @ id
The component in Android needs to be represented by an int value, which is the id attribute value in the component tag. The id attribute can only accept the value of the resource type, that is, the value that must begin with @, such as @ id/abc and @ + id/xyz.
If "+" is used after @, it indicates that after a layout file is modified and saved, the system will automatically generate the corresponding int type variable in the R. java file. The variable name is the value after "/". For example, @ + id/xyz will generate int xyz = value in the R. java file, where value is a hexadecimal number. If xyz already has a variable with the same name in R. java, the new variable is not generated, and the component uses the value of this existing variable.
That is to say, if the form of @ + id/name exists in R. java, the component uses the value of this variable as the identifier. If the variable does not exist, add a new variable and assign the corresponding value to the variable (no duplicates ).
Since the id attribute of a component is a resource id, you can set any existing resource id value, for example, @ drawable/icon, @ string/OK, @ + string/you, etc. Of course, you can also set the existing resource id in the android system. For example, what does android mean by @ id/android: list proposed by the landlord? In fact, this android is the system's R class (in R. the package in the java file. You can enter android. R. id. In the Java code editing area to list the corresponding resource IDs. For example, you can also set the id attribute value to @ id/android: message. <ListView android: id = "@ + id/android: message" android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"/>
You can also view the IDS defined in the system and go to the <android sdk installation project
> \ Platforms \ android-1.5 \ data \ res \ values directory, find the ids. xml file, and open it with the following content:
<? Xml version = "1.0" encoding = "UTF-8"?> <Resources>
<Item type = "id" name = "price_edit"> false </item> <item type = "id" name = "amount_edit"> false </item> </resources>
If ids are defined in ids. xml, @ ID/price_edit can be defined as follows in layout; otherwise, @ + id/price_edit

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.