一、android:id="@+id/button1" 与 android:id="@id/button1" 区别

android:id="@+id/button1"  控件添加一个id这个新的id会自动生成在 R.java文件里面,在你的Activity里面通过 Button btn1 = (Button)findViewById(R.id.button1); 来引用对象了。

android:id="@id/button1"    引用id列表里面已有的id=button1。

二、@string

@string就表示引用了string资源。你去res\values\下应该能找到一个string.xml的文件里面有<string name="hello_world">Hello World</string>这行代码,当然不一定是写的Hello World。这就是定义了一个string资源。可以把两个尖括号中的字改了,再运行就会发现变成改了之后的字。

小结:

@+id 新增一个资源id

@id和android:id,引用现有的资源id

@string就表示引用了string资源

android:id="@+id/button1" 与 android:id="@id/button1" 区别 @string的更多相关文章

  1. Android的Databinding-需要使用控件id,listener以及布局有include的场景

    主的布局xml文件: <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:bin ...

  2. 【我的Android进阶之旅】Android使用getIdentifier()方法根据资源名来获取资源id

    有时候我们想动态的根据一个资源名获得到对应的资源id,就可以使用getResources().getIdentifier()方法来获取该id.然后再使用该id进行相关的操作. 1.Demo示例 下面用 ...

  3. SQL Server output子句用法 output inserted.id 获取刚插入数据的id

    --插入数据,并返回刚刚插入的数据id INSERT INTO [soloreztest] ([name]) output inserted.id VALUES ('solorez') --执行结果: ...

  4. 写出一条Sql语句:取出表A中第31到第40记录(SQLServer,以自动增长的ID作为主键,注意:ID可能不是连续的。

    答:解1:  select top 10 * from A where id not in (select top 30 id from A) 解2:  select top 10 * from A ...

  5. 得到一个div下 特定ID的所有标签

    比如说得到 <div id="showsp"> <div id="a"></div> <div id="a& ...

  6. 写出一条Sql语句:取出表Customer中第31到第40记录(SQLServer,以自动增长的Id作为主键,注意:Id可能不是连续的。

    select top 10 * from (select ROW_NUMBER() over(order by Id) as rows,* from Customer) as C where C.ro ...

  7. 不能收缩 ID 为 %s 的数据库中 ID 为 %s 的文件,因为它正由其他进程收缩或为空。

    SQLServer数据库通常都不建议进行SHRINKFILE操作,因为SHRINKFILE不当会造成一定的性能问题. 但是当进行了某些操作(例如某个超大的日志类型表转成分区表切换了数据文件),数据库某 ...

  8. Html中,id、name、class、type的区别

    <input type="text" name="name" id="name" class="txt"> ...

  9. id: cannot find name for user ID xxx处理办法

    一.现像 root用户登录显示正常但以普通用户登录时报类似如下错误: id: cannot find name for user ID 500id: cannot find name for grou ...

随机推荐

  1. hadoop生态系统的详细介绍

    1.Hadoop生态系统概况 Hadoop是一个能够对大量数据进行分布式处理的软件框架.具有可靠.高效.可伸缩的特点. Hadoop的核心是HDFS和MapReduce,hadoop2.0还包括YAR ...

  2. Block编程值得注意的那些事儿

    [深入浅出Cocoa]Block编程值得注意的那些事儿   [深入浅出Cocoa]Block编程值得注意的那些事儿 罗朝辉 (http://www.cnblogs.com/kesalin/) 本文遵循 ...

  3. java互斥方法

    synchronized,  lock/unlock,  volatile类型变量, atom类, 同步集合,  新类库中的构件: CountDownLatch\CyclicBarric\Semaph ...

  4. 自动获取UILabel的宽度高度

    在使用UILabel存放字符串时,经常需要获取label的长宽数据,本文列出了部分常用的计算方法. 1.获取宽度,获取字符串不折行单行显示时所需要的长度 CGSize titleSize = [aSt ...

  5. FR #3题解

    A. 傻逼题?...前缀和什么的随便搞搞就好了. #include<iostream> #include<cstdio> #include<cstring> #in ...

  6. 文件操作II

    <html> <head> <meta charset="utf-8"> </head> <body> <?php ...

  7. PHP文件系统处理(二)

    1.文件的打开和关闭(读文件中的内容,向文件中写内容)            读取文件中的内容                file_get_contents()     //php5以上 < ...

  8. 破解 Splish

    系统 : Windows xp 程序 : Splish 程序下载地址 :http://pan.baidu.com/s/1o6SA25k 要求 : 注册机编写 & 找出硬编码 使用工具 : OD ...

  9. Inno打包教程_百度经验

    Inno打包教程 Inno工具,是比较常用的打包软件.简简单单,一招叫你学会使用inno打包. 工具/原料 inno setup 软件 方法/步骤 双击桌面的:Inno setup compiler图 ...

  10. Windows Phone 8.1 Page transitions

    original: http://www.visuallylocated.com/post/2014/06/24/Page-transitions-and-animations-in-Windows- ...