国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android 往Framework中添加新資源的方法詳解

2020-04-11 12:10:55
字體:
來源:轉載
供稿:網友
有時候我們想在標準的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:習慣標準化做法。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 湖南省| 邢台市| 汉阴县| 洛扎县| 北碚区| 克东县| 中阳县| 昭通市| 江安县| 西宁市| 新密市| 蕲春县| 西充县| 阳朔县| 瑞金市| 鄂尔多斯市| 广灵县| 阜新市| 建昌县| 手机| 闵行区| 广宗县| 麻栗坡县| 海南省| 大安市| 镇平县| 哈密市| 永安市| 资源县| 简阳市| 罗城| 济宁市| 囊谦县| 彰武县| 翁牛特旗| 保定市| 湖南省| 牟定县| 梅河口市| 沙田区| 铅山县|