最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android編程中@id和@+id的區(qū)別分析

 更新時間:2016年01月09日 08:55:14   作者:tyxkzzf  
這篇文章主要介紹了Android編程中@id和@+id的區(qū)別,較為詳細(xì)的分析講述了Android中資源引入的原理及使用@id和@+id引入資源的具體用法,總結(jié)了二者的區(qū)別,需要的朋友可以參考下

本文分析了Android編程中@id和@+id的區(qū)別。分享給大家供大家參考,具體如下:

Android中的組件需要用一個int類型的值來表示,這個值就是組件標(biāo)簽中的id屬性值。

id屬性只能接受資源類型的值,也就是必須以@開頭的值,例如,@id/abc、@+id/xyz等。

如果在@后面使用“+”,表示當(dāng)修改完某個布局文件并保存后,系統(tǒng)會自動在R.java文件中生成相應(yīng)的int類型變量。變量名就是“/”后面的值,例如,@+id/xyz會在R.java文件中生成int xyz = value,其中value是一個十六進(jìn)制的數(shù)。如果xyz在R.java中已經(jīng)存在同名的變量,就不再生成新的變量,而該組件會使用這個已存在的變量的值。

既然組件的id屬性是一個資源id就可以,那么自然可以設(shè)置任何已經(jīng)存在的資源id值,例如,@drawable/icon、@string/ok、@+string/you等。也可以設(shè)置android系統(tǒng)中已存在的資源id,例如@id/android:list,那么,這個android是什么意思呢,實際上,這個android就是系統(tǒng)的R類(在R.java文件中)所在的package。

我們可以在Java代碼編輯區(qū)輸入android.R.id.,就會列出相應(yīng)的資源id,例如,也可以設(shè)置id屬性值為@id/android:message。

還有另外一種方法查看系統(tǒng)中定義的id,進(jìn)入sdk/platforms/android-16/data/res/values目錄,ids.xml文件;

<?xml version="1.0" encoding="utf-8"?>
<!--
**
** Copyright 2007, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**   http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<resources>
 <item type="id" name="background" />
 <item type="id" name="checkbox" />
 <item type="id" name="content" />
 <item type="id" name="empty" />
 <item type="id" name="hint" />
 <item type="id" name="icon" />
 <item type="id" name="icon1" />
 <item type="id" name="icon2" />
 <item type="id" name="input" />
 <item type="id" name="left_icon" />
 <item type="id" name="list" />
 <item type="id" name="menu" />
 <item type="id" name="message" />
 <item type="id" name="primary" />
 <item type="id" name="progress" />
 <item type="id" name="right_icon" />
 <item type="id" name="summary" />
 <item type="id" name="selectedIcon" />
 <item type="id" name="tabcontent" />
 <item type="id" name="tabhost" />
 <item type="id" name="tabs" />
 <item type="id" name="text1" />
 <item type="id" name="text2" />
 <item type="id" name="title" />
 <item type="id" name="title_container" />
 <item type="id" name="toggle" />
 <item type="id" name="secondaryProgress" />
 <item type="id" name="lock_screen" />
 <item type="id" name="edit" />
 <item type="id" name="widget_frame" />
 <item type="id" name="button1" />
 <item type="id" name="button2" />
 <item type="id" name="button3" />
 <item type="id" name="extractArea" />
 <item type="id" name="candidatesArea" />
 <item type="id" name="inputArea" />
 <item type="id" name="inputExtractEditText" />
 <item type="id" name="selectAll" />
 <item type="id" name="cut" />
 <item type="id" name="copy" />
 <item type="id" name="paste" />
 <item type="id" name="copyUrl" />
 <item type="id" name="selectTextMode" />
 <item type="id" name="switchInputMethod" />
 <item type="id" name="keyboardView" />
 <item type="id" name="closeButton" />
 <item type="id" name="startSelectingText" />
 <item type="id" name="stopSelectingText" />
 <item type="id" name="addToDictionary" />
 <item type="id" name="accountPreferences" />
 <item type="id" name="smallIcon" />
 <item type="id" name="custom" />
 <item type="id" name="home" />
 <item type="id" name="fillInIntent" />
 <item type="id" name="rowTypeId" />
 <item type="id" name="up" />
 <item type="id" name="action_menu_divider" />
 <item type="id" name="icon_menu_presenter" />
 <item type="id" name="list_menu_presenter" />
 <item type="id" name="action_menu_presenter" />
 <item type="id" name="overflow_menu_presenter" />
 <item type="id" name="popup_submenu_presenter" />
</resources>

若在ids.xml中定義了ID,則在layout中可如下定義@id/price_edit,否則@+id/price_edit;

簡單來講:

@+id 新增一個資源id
@id和android:id,引用現(xiàn)有的資源id

希望本文所述對大家Android程序設(shè)計有所幫助。

相關(guān)文章

  • android安裝后啟動出錯解決

    android安裝后啟動出錯解決

    大家好,本篇文章主要講的是android安裝后啟動出錯解決,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽
    2022-01-01
  • Android布局之LinearLayout自定義高亮背景的方法

    Android布局之LinearLayout自定義高亮背景的方法

    這篇文章主要介紹了Android布局之LinearLayout自定義高亮背景的方法,實例分析了Android中LinearLayout布局參數(shù)設(shè)置技巧,需要的朋友可以參考下
    2016-01-01
  • Android中Gallery和ImageSwitcher的使用實例

    Android中Gallery和ImageSwitcher的使用實例

    今天小編就為大家分享一篇關(guān)于Android中Gallery和ImageSwitcher的使用實例,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2019-03-03
  • Android recyclerview實現(xiàn)縱向虛線時間軸的示例代碼

    Android recyclerview實現(xiàn)縱向虛線時間軸的示例代碼

    本文主要介紹了Android recyclerview實現(xiàn)縱向虛線時間軸的示例代碼,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-07-07
  • 詳解Android Bitmap的常用壓縮方式

    詳解Android Bitmap的常用壓縮方式

    這篇文章主要介紹了詳解Android Bitmap的常用壓縮方式,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-01-01
  • Android實現(xiàn)萬能自定義陰影控件實例代碼

    Android實現(xiàn)萬能自定義陰影控件實例代碼

    這篇文章主要給大家介紹了關(guān)于Android實現(xiàn)萬能自定義陰影控件的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對各位Android開發(fā)者們具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • Android 仿網(wǎng)易新聞客戶端分類排序功能

    Android 仿網(wǎng)易新聞客戶端分類排序功能

    這篇文章主要介紹了Android 仿網(wǎng)易新聞客戶端分類排序功能,實現(xiàn)此功能涉及到拖拽item及隱藏拖拽的Item的方法,本文給大家介紹的非常詳細(xì),具有參考借鑒價值,需要的朋友參考下吧
    2016-12-12
  • android實現(xiàn)圖片反轉(zhuǎn)效果

    android實現(xiàn)圖片反轉(zhuǎn)效果

    這篇文章主要介紹了android實現(xiàn)圖片反轉(zhuǎn)效果的方法,需要的朋友可以參考下
    2015-09-09
  • 基于Android實現(xiàn)滾動頭部懸停效果

    基于Android實現(xiàn)滾動頭部懸停效果

    這篇文章主要為大家詳細(xì)介紹了如何在?Android?中實現(xiàn)這種滾動頭部懸停效果,并提供完整源碼,方便學(xué)習(xí)和實際應(yīng)用,有需要的小伙伴可以了解一下
    2025-04-04
  • Android實現(xiàn)用代碼簡單安裝和卸載APK的方法

    Android實現(xiàn)用代碼簡單安裝和卸載APK的方法

    這篇文章主要介紹了Android實現(xiàn)用代碼簡單安裝和卸載APK的方法,涉及Android針對APK文件及package的相關(guān)操作技巧,需要的朋友可以參考下
    2016-08-08

最新評論

西华县| 连云港市| 丘北县| 武宁县| 阜城县| 高密市| 卓资县| 历史| 航空| 龙里县| 岫岩| 玛纳斯县| 枞阳县| 泗阳县| 岐山县| 吴川市| 临沭县| 庆阳市| 新龙县| 公主岭市| 双江| 顺昌县| 绥棱县| 裕民县| 那坡县| 孟村| 益阳市| 常山县| 中宁县| 武夷山市| 大关县| 凤山市| 进贤县| 许昌市| 金阳县| 陵水| 慈溪市| 长泰县| 临漳县| 东乡县| 理塘县|