LayoutInflater.inflate()用法
来源:互联网 发布:淘宝御泥坊官网 编辑:程序博客网 时间:2024/05/18 01:36
inflate()的作用就是将一个用xml定义的布局文件查找出来,注意与findViewById()的区别,inflate是加载一个布局文件,而findViewById则是从布局文件中查找一个控件。
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资源文件的根控件,什么意思呢,就是inflate()会返回一个View对象,如果第三个参数attachToRoot为true,就将这个root作为根对象返回,否则仅仅将这个root对象的LayoutParams属性附加到resource对象的根布局对象上,也就是布局文件resource的最外层的View上,比如是一个LinearLayout或者其它的Layout对象。
attachToRoot:是否将root附加到布局文件的根视图上
0 0
- LayoutInflater、inflate的用法
- LayoutInflater.inflate()用法
- LayoutInflater.inflate()用法
- LayoutInflater的inflate函数用法
- LayoutInflater和inflate的用法
- LayoutInflater和inflate的用法
- LayoutInflater.inflate的用法总结
- 安卓LayoutInflater.inflate用法
- LayoutInflater的inflate函数用法
- LayoutInflater和inflate的用法
- LayoutInflater的inflate函数用法详解,layoutinflater用法
- LayoutInflater的inflate函数用法详解
- LayoutInflater和inflate()方法的用法
- LayoutInflater的inflate函数用法详解
- LayoutInflater的inflate函数用法详解
- LayoutInflater的inflate函数用法详解
- LayoutInflater的inflate函数用法详解
- LayoutInflater和inflate()方法的用法
- ubuntu14.04下phpMyAdmin安装
- 漏洞报告网站收藏
- PCA(主成分分析)的数学原理
- 【笔记】vs2015 使用GIT的时候 “Could not open '***.VC.opendb'”
- Android 视频截图方法
- LayoutInflater.inflate()用法
- node.js Hello world
- asp.net 5.0微信支付
- 使用TextRank算法为文本生成关键字和摘要
- [Leetcode刷题总结系列][Dynamic programming]198. House Robber
- Java单例模式中的线程安全问题
- Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
- 【Get深一度】信号处理(一)——能量信号与功率信号的区别
- warning: no umbrella header found for target 'xxxxx', module map will not be generated