android LayoutInflater.inflate()的参数及其功能
来源:互联网 发布:知乎 日本人的遥远旅途 编辑:程序博客网 时间:2024/05/22 14:36
1.获取LayoutInflater对象有三种方法
LayoutInflater inflater=LayoutInflater.from(this);LayoutInflater inflater=getLayoutInflater();LayoutInflater inflater=(LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
2.关于LayoutInflater类inflate(int resource, ViewGroup root, boolean attachToRoot)方法三个参数的含义
resource:需要加载布局文件的id,意思是需要将这个布局文件中加载到Activity中来操作。
root:需要附加到resource布局资源文件的根控件, 如果第三个参数attachToRoot为true,并且root不为null那么将xml布局文件挂载到root下面,相当于根元素是root。 如果root不为null,attachToRoot设为false,则会将布局文件最外层的所有layout属性进行设置,当该view被添加到父view当中时,这些layout属性会自动生效。如果root为null,attachToRoot将失去作用,设置任何值都没有意义。
所以这个参数的作用就是,是否把选取的视图加入到root中。false 的意思就是不添加到root中。可能需要我们手动添加。但是我们可以利用root.addView(view)函数吧这个布局手动添加到root布局中去。
参考:
关于inflate的第3个参数
inflate参数
0 0
- android LayoutInflater.inflate()的参数及其功能
- android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数及其用法
- 关于android LayoutInflater.inflate()的参数及其用法
- android LayoutInflater.inflate()的参数介绍
- Android研发安全1-Activity组件安全(上)
- h5大文件断点续传
- 设置adb server的端口号
- css中 margin: 0px 254px 0px 254px; 是什么意思。
- 两种优化查询的方法
- android LayoutInflater.inflate()的参数及其功能
- 设置密码输入框明文和密文切换
- 设计模式六大原则
- CentOS python 2.x 升到 3.x 遇到的一些问题记录
- 网站建设的流程
- SQL语句大提升
- 客户端动态化系列之——Weex
- hdu 1207 汉诺塔II 递推关系
- Docker命令使用详解