• @+id/和android:id有什么区别?


    Any View object may have an integer ID associated with it, to uniquely identify the View within the tree. When the application is compiled, this ID is referenced as an integer, but the ID is typically assigned in the layout XML file as a string, in the id attribute. This is an XML attribute common to all View objects (defined by the View class) and you will use it very often. The syntax for an ID, inside an XML tag is:
    android:id="@+id/my_button"

    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 the R.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 the android package namespace, like so:
    android:id="@android:id/empty"

    android:id="@+id/btn",表示在R.java文件里面新增一个id为btn的控件索引,最常用的一种声明控件id的方式。android:id="@android:id/tabhost",表示引用的是系统已有的ID,在对应的sdk目录下的ids.xml里面。一般外部不去调用,是组件内部调用的时候使用。.android:id="@id/btn"  ,表示引用一个已经存在的ID,在R.java里面的,比如我们自己建了一个ids.xml,里面声明了一组id,其中一个是btn,那么你就可以这样引用了。

  • 相关阅读:
    面向消息的持久通信与面向流的通信
    通信协议
    [1]序章,基本
    深拷贝和浅拷贝
    堆/栈 内存管理相关
    C++的四种cast(显示类型转换)
    智能指针相关
    C++对象模型:单继承,多继承,虚继承
    HTTP/TCP
    [读书笔记] 为什么绝不在构造/析构函数中调用virtual函数
  • 原文地址:https://www.cnblogs.com/KevinJasmine/p/3753031.html
Copyright © 2020-2023  润新知