How Android adds new resources to the framework _android

Source: Internet
Author: User
How do we sometimes want to add our own new resources to the standard framework?
The idea is for us to try.
Through Eclipse's connection, we can relate to whether it is simply putting strings in the various folders of Res. First to try, compile, the system immediately error. Why, then?
It prompts you to use make UPDATE-API this command to update the Public.xml file or to refer to this statement as the hide type. This is definitely not what we want.
So there are two ways:
Method 1:
After the resource has been added normally, execute the Make Update-api function. The system updates the Res/values/public.xml file.
Method 2:After the resource has been added normally, manually change the/res/values/public.xml file. Open the Public.xml file. The discovery structure is as follows:
Copy Code code as follows:

<resources>
<!--We don ' t want to publish private symbols into ANDROID.R as part of the
Sdk. Instead, put the them here. -->
<private-symbols package= "Com.android.internal"/>
<!--androidmanifest.xml attributes. -->
<eat-comment/>
<!--===============================================================
Resources for version 1 of the platform.
===============================================================-->
<eat-comment/>
<public type= "string" name= "Cancel" id= "0x01040000"/>
<public type= "string" name= "copy" id= "0x01040001"/>
<public type= "string" name= "Copyurl" id= "0x01040002"/>
<public type= "Style" Name= "TextAppearance.Widget.TextView.SpinnerItem" id= "0x01030052"/>
<public type= "Style" Name= "Textappearance.windowtitle" id= "0x01030053"/>
<public type= "attr" name= "theme" id= "0x01010000"/>
<public type= "attr" name= "label" id= "0x01010001"/>
<public type= "attr" name= "icon" id= "0x01010002"/>
<public type= "attr" name= "name" id= "0x01010003"/>
<public type= "attr" name= "managespaceactivity" id= "0x01010004"/>
<public type= "attr" name= "Allowclearuserdata" id= "0x01010005"/>
<public type= "attr" name= "permission" id= "0x01010006"/>
<public type= "attr" name= "readpermission" id= "0x01010007"/>
<public type= "attr" name= "writepermission" id= "0x01010008"/>
<public type= "attr" name= "ProtectionLevel" id= "0x01010009"/>
<!--===============================================================
Added in version 7 of the platform (Eclair MR1).
===============================================================-->
<eat-comment/>
<public type= "attr" name= "author" id= "0x010102b4"/>
<public type= "attr" name= "AutoStart" id= "0x010102b5"/>
</resources>

In this way, we can add our own hands.
Recommended Method 1, is also the most standard approach. Why?
1: Avoid duplicate IDs.
2: Trouble
3: Customary standardization procedure.

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.