展会信息港展会大全

关于android xml文件中 android:id="@+id/my_button"的含义疑问
来源:互联网   发布日期:2015-12-08 16:50:09   浏览:1648次  

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

许多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 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"

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

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

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

摘自:Octobershiner的专栏

赞助本站

人工智能实验室

相关热词: android开发 教程

下一篇:没有了...
AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港