The use of Android--ids.xml files

Source: Internet
Author: User

1. When we use the control, sometimes it is unavoidable to declare the ID for the control, and scattered in the various XML files, sometimes it is not particularly convenient to find, so, Android has provided us with the Ids.xml file, saved in Res--valuse--Ids.xml In the file

2. Benefits of using the Ids.xml file

    

1. Convenient naming, we can put some specific controls first name, we use the time directly in our layout to set the ID, save a naming link. 2. When we write the code layout, when we set the ID, we need to use this method to name our control, it can be found in the R file to find the corresponding ID, and then to convert. Note: Each item in Ids.xml will also be generated into the R file, as the above Ids.xml will generate the following control in our R file: public static final class ID {public static final intbutton_ok=0x7f080000;public static final intdialog_exit=0x7f080001;When we use it, no matter which way you set the ID, it is the same: Findviewbyid (R.ID.XXX); 3. Format is ready to use
<?xml version= "1.0" encoding= "Utf-8"?><resources> <item    type= "id" name= "logo" >false</item >    <item type= "id" name= "showtext" >false</item></resources>

The use of Android--ids.xml files

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.