发布于 2016-02-22 23:23:57 | 133 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

Android移动端操作系统

Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。尚未有统一中文名称,中国大陆地区较多人使用“安卓”或“安致”。


本篇文章是对Android往Framework中添加新资源的方法进行了详细的分析介绍,需要的朋友参考下
有时候我们想在标准的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:习惯标准化做法。


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务