How Android adds new resources to the Framework

Source: Internet
Author: User

Sometimes we want to add new resources in the standard Framework. What should we do?
The solution is to try it.
Through the Eclipse contact, we can think of whether it is simply to put the string in each folder of res. Let's try it out first, compile it, and the system reports an error immediately. Why?
It prompts you to use the make update-api command to update the public. xml file or call this Declaration the hide type. This is definitely not what we want.
So there are two methods:
Method 1:
After adding resources, execute the make update-api function. The system updates the res/values/public. xml file.
Method 2:After adding resources, manually change the/res/values/public. xml file. Open the public. xml file. The found structure is as follows: Copy codeThe Code is as follows: <resources>
<! -- We don't want to publish private symbols in Android. R as part of
SDK. Instead, put 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 = "0 x01040002"/>
<Public type = "style" name = "TextAppearance. Widget. TextView. SpinnerItem" id = "0x01030052"/>
<Public type = "style" name = "TextAppearance. WindowTitle" id = "0 x01030053"/>
<Public type = "attr" name = "theme" id = "0 x01010000"/>
<Public type = "attr" name = "label" id = "0x01010001"/>
<Public type = "attr" name = "icon" id = "0x01010002"/>
<Public type = "attr" name = "name" id = "0 x01010003"/>
<Public type = "attr" name = "Manager activity" id = "0x01010004"/>
<Public type = "attr" name = "allowClearUserData" id = "0 x01010005"/>
<Public type = "attr" name = "permission" id = "0 x01010006"/>
<Public type = "attr" name = "readPermission" id = "0 x01010007"/>
<Public type = "attr" name = "writePermission" id = "0 x01010008"/>
<Public type = "attr" name = "protectionLevel" id = "0 x01010009"/>
<! -- ===================================================== ======================================
Resources 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 them by ourselves.
Recommended method 1 is also the most standard practice. Why?
1: Avoid duplicate IDs.
2: Trouble
3: standardized practices.

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.