码迷,mamicode.com
首页 > 其他好文 > 详细

LayoutInflater和inflate()方法的用法

时间:2014-09-28 16:00:44      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:android

    public static LayoutInflaterfrom(Context context) {

        LayoutInflaterLayoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        if(LayoutInflater== null){

            thrownew AssertionError("LayoutInflaternot found.");

        }

        returnLayoutInflater;

    }

可以看出它其实调用context.getSystemService()。

 

 

public View inflate(int Resourece,ViewGrouproot)
作用:填充一个新的视图层次结构从指定的XML资源文件中
reSource:View的layout的ID
root: 生成的层次结构的根视图
return 填充的层次结构的根视图。如果参数root提供了,那么root就是根视图;否则填充的XML文件的根就是根视图。

其余几个重载的inflate函数类似。



LayoutInflater和inflate()方法的用法

标签:android

原文地址:http://blog.csdn.net/chuyuqing/article/details/39642319

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!