Android 往 Framework中添加新的资源
2013-03-06 12:47
253 查看
有时候我们想在标准的Framework中添加自己的新的资源怎么办呢?
办法就是我们来尝试下。
通过Eclipse的联系,我们可以联想到是否就是简单的把字符串放在res的各个文件夹里面。先来试试看,编译,系统立即报错。为什么呢?
它提示你利用make update-api这个命令来更新public.xml文件或者把这个声明称hide类型。这个肯定不是我们想要的。
所以方法有二:
方法1:正常添加完资源后,执行make update-api函数。系统更新res/values/public.xml文件。
方法2:正常添加完资源后,手动更改/res/values/public.xml文件。打开public.xml文件。发现结构如下:
<resources>
<!-- We don't want to publish private symbols in Android.R as part of the
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="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" />
<!-- ===============================================================
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>
这样,我们可以自己动手添加。
推荐方法1,也是最标准的做法。为啥?
1:避免id重复。
2:麻烦
3:习惯标准化做法。
办法就是我们来尝试下。
通过Eclipse的联系,我们可以联想到是否就是简单的把字符串放在res的各个文件夹里面。先来试试看,编译,系统立即报错。为什么呢?
它提示你利用make update-api这个命令来更新public.xml文件或者把这个声明称hide类型。这个肯定不是我们想要的。
所以方法有二:
方法1:正常添加完资源后,执行make update-api函数。系统更新res/values/public.xml文件。
方法2:正常添加完资源后,手动更改/res/values/public.xml文件。打开public.xml文件。发现结构如下:
<resources>
<!-- We don't want to publish private symbols in Android.R as part of the
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="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" />
<!-- ===============================================================
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>
这样,我们可以自己动手添加。
推荐方法1,也是最标准的做法。为啥?
1:避免id重复。
2:麻烦
3:习惯标准化做法。
相关文章推荐
- Android framework中修改或者添加资源无变化或编译不通过问题详解
- Android framework中修改或者添加资源无变化或编译不通过问题详解
- android源码framework下添加新资源的方法
- Android 往Framework中添加新资源的方法详解
- 添加资源到android源码中-修改framework层
- android源码framework下添加新资源的方法
- android源码framework下添加新资源的方法 .
- android framework中添加资源文件
- 添加资源到android源码中-修改framework层
- android源码framework下添加新资源的方法
- 底层 添加资源到android源码中-修改framework层
- android 往 Framework中添加新的资源
- android framework中添加私有资源文件
- Android framework/base/core/res 中添加资源文件编译
- 在android源码framework里添加的资源文件!
- android源码framework下添加新资源的方法
- android源码framework下添加新资源的方法
- Android 往Framework中添加新资源的方法详解
- framework添加res资源并打包进新的Android.jar
- Android 修改framework下资源文件后如何编译