所以这是我的问题.我决定为自己编写一个小应用程序,同时我也在努力学习Android开发.我知道为什么androID:ID属性中有一个+
(plus)符号,因为它意味着“创建一个新的ID资源”.但我不知道为什么AndroID需要放入用于引用的内容,如下所示:
这里我有两个名为Startbutton和Stopbutton的按钮,因为它们是新资源,androID:ID包含:
<button androID:ID="@+ID/Startbutton" androID:layout_wIDth="150dp" androID:layout_height="wrap_content" androID:layout_alignParentleft="true" androID:layout_below="@+ID/textVIEw1" androID:layout_margintop="53dp" androID:textSize="18dp" androID:text="Start" androID:onClick="Startbutton_OnClick" /><button androID:ID="@+ID/Stopbutton" androID:layout_wIDth="150dp" androID:layout_height="wrap_content" androID:layout_aligntop="@+ID/Startbutton" androID:layout_toRightOf="@+ID/Startbutton" androID:text="Stop" androID:textSize="18dp" tools:context=".CallerBlockerActivity" androID:onClick="Stopbutton_OnClick" />
但是为什么androID:layout_aligntop包含了谜题,因为当@ ID / Stopbutton到达它时定义了ID / Startbutton.有人可以解释一下这种语法的必要性吗?
解决方法 无论哪种方式都无关紧要 – 只需要第一次引用ID即可.如果已定义ID,则无论如何都会被忽略.如果您愿意,可以在XML中的每个引用之前放置一个,并且一切都将按预期工作.不过,这只是第一次参考的必要条件. 总结以上是内存溢出为你收集整理的为什么“加号”会在Android中引用名称中为ID资源签名全部内容,希望文章能够帮你解决为什么“加号”会在Android中引用名称中为ID资源签名所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)