关于安卓XML布局里面的引用与代码顺序
2016-12-31 05:11
281 查看
我有一个问题
首先看这段伪代码
<RelativeLayout>
<Button android:id="@+id/toast_dialog_confirm"/>
<Button
android:id="@+id/toast_dialog_cancel"
android:layout_toLeftOf="@+id/toast_dialog_confirm" />
</RelativeLayout>
要实现的效果是【后面的一个Button放到前一个Btn的左边】
然后再看这段
<RelativeLayout>
<Button
android:id="@+id/toast_dialog_cancel"
android:layout_toLeftOf="@+id/toast_dialog_confirm" />
<Button
android:id="@+id/toast_dialog_confirm"/>
</RelativeLayout>
确实以上两段都可以实现目标功能
但是第二段代码会不会有隐患,会不会因为XML的读取顺序出现“toast_dialog_confirm”找不到的情况
就是会不会出现那种【还未读取到这个Btn但已经引用了这个Btn的错误】
需要说明的是这两个Btn都已经写到了代码中
首先看这段伪代码
<RelativeLayout>
<Button android:id="@+id/toast_dialog_confirm"/>
<Button
android:id="@+id/toast_dialog_cancel"
android:layout_toLeftOf="@+id/toast_dialog_confirm" />
</RelativeLayout>
要实现的效果是【后面的一个Button放到前一个Btn的左边】
然后再看这段
<RelativeLayout>
<Button
android:id="@+id/toast_dialog_cancel"
android:layout_toLeftOf="@+id/toast_dialog_confirm" />
<Button
android:id="@+id/toast_dialog_confirm"/>
</RelativeLayout>
确实以上两段都可以实现目标功能
但是第二段代码会不会有隐患,会不会因为XML的读取顺序出现“toast_dialog_confirm”找不到的情况
就是会不会出现那种【还未读取到这个Btn但已经引用了这个Btn的错误】
需要说明的是这两个Btn都已经写到了代码中
相关文章推荐
- 自学安卓复习基础_之八(关于重写页面布局,引用自定义页面布局)
- 利用python读取xml布局文件下面使用中文或者引用资源文件里面的中文,并且显示行号
- 安卓 相机或相册图片上传至手机界面并显示 最后上传至服务器(界面xml布局代码前一个文章有)
- 关于使用eclipse开发安卓时布局界面XML的graphical layout没有显示的问题
- 安卓界面里面弹出“关于我们”的说明代码实现
- 关于Android中http请求Gosn解析的一些个人见解: 首先是XML中构建布局: 在布局里面建一个listview用来展示Gson解析的字符
- Android 在XML里面共享同一布局文件
- SD--关于定价过程中的存储顺序的参考结构和参考字段的使用代码跟踪
- 读取xml实现问卷调查,关于问卷调查的内容全部放在了xml里面,使用了jQuery
- 关于log4j中log4j.properties和log4j.xml的加载顺序
- 创建模块化游戏(Creating Moddable Games with XML and Scripting Part I)代码阅读,关于整体架构!
- [Android UI界面] 你导入工程的时候遇没遇到过,工程里面的xml文件就有代码,没有可见视图界面,并且写代码的时候还联想不出来
- js引用里面再写绑定blur事件导致代码失灵的问题备忘
- 关于DataBind和页面代码执行顺序
- 关于C++里面折叠代码的两招
- 关于在xcode里面c++代码与objective-c代码混编的问题
- Animation Tween动画可以通过java代码实现,也可以通过xml布局来实现
- 布局xml中的属性设置如何在代码中实现
- 关于net2.0里面新出现的类backgroundworker的应用 --引用自http://www.cnblogs.com/dlwang2002/archive/2006/12/07/585093.html
- 一个关于继承关系中静态快、成员变量、构造体代码的执行顺序的Java代码