`
ai_longyu
  • 浏览: 482041 次
社区版块
存档分类
最新评论

关于android xml文件中 android:id="@+id/my_button"的含义疑问

 
阅读更多

许多UI开发的同学会对 android:id="@+id/my_button"的含义有所疑问,细心的同学会发现官方SDK是这样解释的,

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

The at-symbol (@) at the beginning of the string indicates that the XML parser should parse and expand the rest of the ID string and identify it as an ID resource. The plus-symbol (+) means that this is a new resource name that must be created and added to our resources (in theR.javafile). There are a number of other ID resources that are offered by the Android framework. When referencing an Android resource ID, you do not need the plus-symbol, but must add theandroidpackage namespace, like so:

android:id="@android:id/empty"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------


意思也就是说 @符号要通知xml要转换@后面的字符串为ID资源,而+号表示这是要创建一个新的资源名字,并且添加到R.java文件中。

当你要引用已有的资源的时候 可以直接写成 @android:id/empty

分享到:
评论

相关推荐

    SendSms.zip

    适合android初学者 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" ...

    深入理解Android中的xmlns:tools属性

    前言 安卓开发中,在写布局代码的时候,ide可以看到布局的预览效果。...android:id=@+id/text_main android:layout_width=match_parent android:layout_height=wrap_content android:textAppearance=@style/Te

    Android实训购物车页面

    android:text="确定购买"> </Button> <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/gouwuquxiao" android:text="取消购买"> </Button> </LinearLayout> </...

    android自定义弹出框

    android:id="@+id/buttons" android:layout_below="@id/msg" android:padding="5dip" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:layout_width="135dip" android:...

    Android购物车代码

    -<LinearLayout android:background="@drawable/aaa" android:weightSum="1" android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" xmlns:android=...

    [Android应用开发电子书]

    <?xml version="1.0" encoding="utf-8"?> android:id="@+id/widget0" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" ...

    Android 重写RadioButton,模仿QQ消息气泡

    android:id="@+id/rb_sys_set" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:button="@null" android:drawableTop="@drawable/icon_click_wd" ...

    android中ratingbar的简单使用

    android控件的展示 ... android:id="@+id/ratingbarId" android:layout_height="wrap_content" android:layout_width="wrap_content" android:numStars="5" android:stepSize="1.0" /> </LinearLayout>

    九宫格牌翻转游戏demo

    java关键代码: mText = (TextView) findViewById(R.id.textView1); mImageView01 = (ImageView) findViewById(R.id.m1); mButton = (Button) findViewById(R.id.button1);... android:id="@+id/button1" ...

    WebViewDownloadTest.zip

    废话不多少了,先上布局,布局文件非常简单,一个EditText和一个Button被填充在LinearLayout中其余部分全部留给WebView ``` <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android=...

    android 音乐播放器

    android:id="@+id/signer"//id android:layout_marginLeft="20px" android:textSize="14sp" android:text="歌手" android:textStyle="bold" /> ImageView <ImageView//定义图片显示组件名称 android:id="@...

    Android 加载动画的实现

    Android加载动画的简单实现,<?xml version="1.0" encoding="utf-8"?> xmlns:android="http://schemas.android.com/apk/res/android" android: <item android:duration="130" android:drawable="@...

    ratingbar 自定义星星效果

    <item android:id="@+android:id/background" android:drawable="@drawable/xixi0" /> <item android:id="@+android:id/secondaryProgress" android:drawable="@drawable/xixi0" /> <item android:id="@+...

    GridView+BaseAdapter的使用

    android:id="@+id/img_logo" android:layout_width="60dp" android:layout_height="60dp" android:src="@drawable/ic_launcher" /> android:id="@+id/tv_name" android:layout_width="60dp" android:...

    Android布局管理器

    11 android:id="@+id/Button01" 12 android:layout_width="wrap_content" 13 android:layout_height="wrap_content"> 14 </Button> <!-- 声明一个 Button 布局,并设置其 id 为 Button01 --> 15 </LinearLayout>

    Android自定义SeekBar滑动显示数字

    先来上个效果图: 当滑动时:数值显示,滑动停止时显示数字,使用FrameLayout结合SeekBar。 首先我们看看。 Layout: <?xml version=1.0 encoding=utf-... android:id=@+id/wrapper_seekbar_indicator android:la

    android基础

    第二种方法实现界面布局:布局文件(layout中的activty_main.xml) 其实就是标签的嵌套,注意单标签、双标签 拨打电话的实现: 布局activity_main.xml: <LinearLayout xmlns:android=...

    java计算器代码.txt

    java计算器开发源码,<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=... android:id="@+id/lay_title" android:layout_width="fill_parent" >

    inote记事工具android客户端

    <RadioGroup android:id="@+id/searchRadioGroup" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <RadioButton android:layout_height="wrap_...

    android顶部滑动导航

    android:id="@+id/sayit_rl_tab" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:background="#F2F2F2" > android:id="@+id/sayit_...

Global site tag (gtag.js) - Google Analytics