Instantiates a layout XML file into itscorresponding View objects.

LayoutInflater作用是将layout的xml布局文件实例化为View类对象。

inflate 是 LayoutInflater 的方法 作用是将指定xml中的布局找出来

我把inflate翻译为填充

LayoutInflater:

作用: 
1、对于一个没有被载入或者想要动态载入的界面, 都需要使用inflate来载入. 
2、对于一个已经载入的Activity, 就可以使用实现了这个Activiyt的的findViewById方法来获得其中的界面元素.

Inflater:

通俗的说,inflate就相当于将一个xml中定义的布局找出来.

 三种方式可以生成LayoutInflater:

  LayoutInflaterinflater=LayoutInflater.from(this);
  LayoutInflaterinflater=getLayoutInflater();
  LayoutInflaterinflater=(LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);

ex:

LayoutInflater inflater = (LayoutInflater) context

.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

inflater.inflate(R.layout.title_view,
this, true);//找出xml 到view容器

ex2:

LayoutInflatermLi = LayoutInflater .from(this);

View view1 = mLi.inflate(R.layout.view1,
null);

View view2 = mLi.inflate(R.layout.view2,
null);

View view3 = mLi.inflate(R.layout.view3,
null);

ex3:

mViewGroup = (ViewGroup) mInflater.inflate(mresource,null);

note:第一个参数是布局,第二个参数是ViewGroup 是可以为空的

View convertView

convertView = mInflater.inflate(mresource, null);

LayoutInflater 与 inflate的更多相关文章

  1. 转载《 LayoutInflater 的inflate函数用法详解》

    很多人在网上问LayoutInflater类的用法,以及inflate()方法参数的含义,现解释如下: inflate()的作用就是将一个用xml定义的布局文件查找出来,注意与findViewById ...

  2. View.inflate和LayoutInflater的inflate方法区别

    平时ListView加载item中,adapter的getView方法中,我们经常用到: LayoutInflater.from(mContext).inflate(R.layout.it ,pare ...

  3. 三个案例带你看懂LayoutInflater中inflate方法两个参数和三个参数的区别

    关于inflate参数问题,我想很多人多多少少都了解一点,网上也有很多关于这方面介绍的文章,但是枯燥的理论或者翻译让很多小伙伴看完之后还是一脸懵逼,so,我今天想通过三个案例来让小伙伴彻底的搞清楚这个 ...

  4. Android编程之LayoutInflater的inflate方法具体解释

    LayoutInflater的inflate方法,在fragment的onCreateView方法中经经常使用到: public View onCreateView(LayoutInflater in ...

  5. 转载 LayoutInflater的inflate函数用法详解

    http://www.open-open.com/lib/view/open1328837587484.html LayoutInflater的inflate函数用法详解 LayoutInflater ...

  6. Android编程之LayoutInflater的inflate方法实例

    假设你不关心其内部实现,仅仅看怎样使用的话,直接看这篇就可以. 接上篇,接下来,就用最最简单的样例来说明一下: 用两个布局文件main 和 test: 当中,main.xml文件为: <?xml ...

  7. LayoutInflater和inflate的用法,有图有真相

    1.概述 有时候在我们的Activity中用到别的layout,并且要对其组件进行操作,比如: A.acyivity是获取网络数据的,对应布局文件为A.xml,然后需要把这个数据设置到B.xml的组件 ...

  8. Android编程之LayoutInflater的inflate方法详解

    LayoutInflater的inflate方法,在fragment的onCreateView方法中经常用到: public View onCreateView(LayoutInflater infl ...

  9. 带你看懂LayoutInflater中inflate方法

    关于inflate问题,我想很多人多多少少都了解一点,网上也有很多关于这方面介绍的文章,但是枯燥的理论或者翻译让很多小伙伴看完之后还是一脸懵逼,so,我今天想通过三个案例来让小伙伴彻底的搞清楚这个东东 ...

  10. LayoutInflater的inflate函数用法详解

    LayoutInflater作用是将layout的xml布局文件实例化为View类对象. 获取LayoutInflater的方法有如下三种: LayoutInflater inflater=(Layo ...

随机推荐

  1. webpy + nginx + fastcgi 构建python应用

    1.准备环境 CentOs  6.3 nginx-1.4.2.tar.gz            http://nginx.org/download/nginx-1.4.2.tar.gz openss ...

  2. oracle中job定时调用存储过程的实例

    使用job模拟定时从元数据表中抽取指定数据进入目标表的过程. 一.创建元数据表 --create table test_origianl create table test_original_data ...

  3. HTML5的结构学习(1) --- 新增的主体结构元素

      1.article 元素 解释:代表文档.页面和应用程序中独立的.完整的.可以被独自引用的内容. 主要用途:博客中的文章.评论,贴吧中的帖子,或者独立的插件等. article中可以包含多种元素例 ...

  4. tp其他功能

    数据缓存 在ThinkPHP中进行缓存操作,一般情况下并不需要直接操作缓存类,因为系统内置对缓存操作进行了封装,3.1版本推荐的数据缓存方法是cache方法,基本的用法是:(3.1.2版本cache方 ...

  5. API例子:用Python驱动Firefox采集网页数据

    1,引言 本文讲解怎样用Python驱动Firefox浏览器写一个简易的网页数据采集器.开源Python即时网络爬虫项目将与Scrapy(基于twisted的异步网络框架)集成,所以本例将使用Scra ...

  6. LINUX下QT与C语言通过网卡名获取网卡IP与MAC

    1.QT下 QString RuntimeConfig::ipAddress(QString network) { QList<QNetworkAddressEntry> list; QS ...

  7. 【Robot Framework 介绍】总纲

    Robot Framework是一个由python构建的的开源的自动化测试框架,现在版本还在不停的更新中.由于它开源性,网上有大量的第三方接口和很多资料.下面提供两个比较官方的链接,有兴趣的同学可以直 ...

  8. Intuit Quicken Home & Business 2016(Manage your business and personal finances)

    Quicken Home & Business 2016 - Manage your business and personal finances all in one place. Cate ...

  9. asp.net mvc,做 301 永久重定向

    以下代码为 asp.net mvc 4.0 代码做的 301 永久重定向 string url = “http://www.csdn.net/test.html” Response.StatusCod ...

  10. Windows查看电脑上安装的.Net Framework版本的五种方法(转)

    1.查看安装文件判断Framwork版本号 打开资源管理器,比如我的电脑,再地址栏输入%systemroot%\Microsoft.NET\Framework后单击“转到”或者按回车. 在新文件夹中查 ...