许多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.java
file). 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 theandroid
package namespace, like so:
android:id="@android:id/empty"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
意思也就是说 @符号要通知xml要转换@后面的字符串为ID资源,而+号表示这是要创建一个新的资源名字,并且添加到R.java文件中。
当你要引用已有的资源的时候 可以直接写成 @android:id/empty
分享到:
相关推荐
适合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" ...
前言 安卓开发中,在写布局代码的时候,ide可以看到布局的预览效果。...android:id=@+id/text_main android:layout_width=match_parent android:layout_height=wrap_content android:textAppearance=@style/Te
android:text="确定购买"> </Button> <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/gouwuquxiao" android:text="取消购买"> </Button> </LinearLayout> </...
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:...
-<LinearLayout android:background="@drawable/aaa" android:weightSum="1" android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" xmlns: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: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控件的展示 ... android:id="@+id/ratingbarId" android:layout_height="wrap_content" android:layout_width="wrap_content" android:numStars="5" android:stepSize="1.0" /> </LinearLayout>
java关键代码: mText = (TextView) findViewById(R.id.textView1); mImageView01 = (ImageView) findViewById(R.id.m1); mButton = (Button) findViewById(R.id.button1);... android:id="@+id/button1" ...
废话不多少了,先上布局,布局文件非常简单,一个EditText和一个Button被填充在LinearLayout中其余部分全部留给WebView ``` <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android=...
android:id="@+id/signer"//id android:layout_marginLeft="20px" android:textSize="14sp" android:text="歌手" android:textStyle="bold" /> ImageView <ImageView//定义图片显示组件名称 android:id="@...
Android加载动画的简单实现,<?xml version="1.0" encoding="utf-8"?> xmlns:android="http://schemas.android.com/apk/res/android" android: <item android:duration="130" android:drawable="@...
<item android:id="@+android:id/background" android:drawable="@drawable/xixi0" /> <item android:id="@+android:id/secondaryProgress" android:drawable="@drawable/xixi0" /> <item android:id="@+...
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:...
11 android:id="@+id/Button01" 12 android:layout_width="wrap_content" 13 android:layout_height="wrap_content"> 14 </Button> <!-- 声明一个 Button 布局,并设置其 id 为 Button01 --> 15 </LinearLayout>
先来上个效果图: 当滑动时:数值显示,滑动停止时显示数字,使用FrameLayout结合SeekBar。 首先我们看看。 Layout: <?xml version=1.0 encoding=utf-... android:id=@+id/wrapper_seekbar_indicator android:la
第二种方法实现界面布局:布局文件(layout中的activty_main.xml) 其实就是标签的嵌套,注意单标签、双标签 拨打电话的实现: 布局activity_main.xml: <LinearLayout xmlns:android=...
java计算器开发源码,<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=... android:id="@+id/lay_title" android:layout_width="fill_parent" >
<RadioGroup android:id="@+id/searchRadioGroup" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <RadioButton android:layout_height="wrap_...
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_...