LayoutInflater 简要解析
2015-07-27 16:31
447 查看
LayoutInflater 是一个抽象类,在文档中如下声明:
public abstract class LayoutInflater extends Object
获得 LayoutInflater 实例的三种方式
这三种方式,实质上是一样的,getLayoutInflater()会调用LayoutInflater.from(context),LayoutInflater.from(context)会调用第三个。
root参数,通常为null,
如果设置了root,将返回整个ViewGroup,否则返回填充的Layout。
public abstract class LayoutInflater extends Object
获得 LayoutInflater 实例的三种方式
1. LayoutInflater inflater = getLayoutInflater();//调用Activity的getLayoutInflater() 2. LayoutInflater inflater = LayoutInflater.from(context); 3. LayoutInflater inflater = (LayoutInflater)context.getSystemService (Context.LAYOUT_INFLATER_SERVICE);
这三种方式,实质上是一样的,getLayoutInflater()会调用LayoutInflater.from(context),LayoutInflater.from(context)会调用第三个。
public View inflate (int resource, ViewGroup root) public View inflate (XmlPullParser parser, ViewGroup root) public View inflate (XmlPullParser parser, ViewGroup root, boolean attachToRoot) public View inflate (int resource, ViewGroup root, boolean attachToRoot)
root参数,通常为null,
Parameters: resource ID for an XML layout resource to load (e.g., R.layout.main_page) root Optional view to be the parent of the generated hierarchy. Returns: The root View of the inflated hierarchy. If root was supplied, this is the root View; otherwise it is the root of the inflated XML file.
如果设置了root,将返回整个ViewGroup,否则返回填充的Layout。
相关文章推荐
- [转载]Activity中ConfigChanges属性的用法
- android之定时器AlarmManager
- Android java 与 javascript互访(相互调用)的方法例子
- Web布局连载——两栏固定布局(五)
- android上改变listView的选中颜色
- 转载:On having layout
- Android中layout属性大全
- android layout XML解析错误的解决方法
- 基于Android LayoutInflater的使用介绍
- zend Framework中的Layout(模块化得布局)详解
- Auto Layout on iOS Versions prior to 6.0 解决办法
- Android布局
- layoutSubviews 详解
- LayoutInflater与findViewById的用法
- SimpleCursorAdapter类与数据绑定
- LayoutInflater的使用
- android:layout_gravity和android:gravity属性的区别
- android 选择本地图片并截剪图片保存到,sdcard指定目录中
- ExtJS之 标准布局类(针对于panel)
- Android4.4新的特性,在应用内开启透明状态栏和透明虚拟按钮。