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. MySQL数据库主从同步安装与配置总结

    MySQL的主从同步是一个很成熟的架构,优点为: ①在从服务器可以执行查询工作(即我们常说的读功能),降低主服务器压力: ②在从主服务器进行备份,避免备份期间影响主服务器服务: ③当主服务器出现问题时 ...

  2. codeforces 518A. Vitaly and Strings

    A. Vitaly and Strings time limit per test 1 second memory limit per test 256 megabytes input standar ...

  3. JVM的体系结构——JVM之三

    JVM的内部体系结构分为四部分, (1)类装载器(ClassLoader)子系统 作用: 用来装载.class文件 (2)执行引擎 作用:执行字节码,或者执行本地方法 (3)垃圾回收子系统 作用:垃圾 ...

  4. UI组件

    1.自定义View 2.布局管理器-----ViewGroup 3.textview及其子类 4.imageview及其子类 5.adapterview及其子类----ViewGroup 6.prog ...

  5. C# 几种常见的排序方法

    1.冒泡排序 //冒泡排序 public void BubbleSort(int[] list) { int i, j, temp; bool done = false; j = ; while (( ...

  6. QT 小票打印

    原地址: http://www.cppblog.com/biao/archive/2009/09/08/95603.html QString htmlString = QString("&l ...

  7. 使用myeclipse生成的HibernateSessionFactory的合理性

    作为简单的一个单件模式, getSessionFactory()函数返回null是一个不合理的决定,可以返回一个没有初始化的SessionFactory对象,但是返回null就和这种模式的语意有冲突了 ...

  8. firebug加载不了js脚本文件问题

    转载自:http://tieba.baidu.com/p/1008322286 现象: 页面中有加载js文件,但是firebug却提示:    本页面不包含 Javascript 如果 <scr ...

  9. [分享]源代码&开发手记:SAE应用“车百科” (Python + SAE + Bottle + Bootstrap) - Bottle - Python4cn(news, jobs)

    [分享]源代码&开发手记:SAE应用"车百科" (Python + SAE + Bottle + Bootstrap) - Bottle - Python4cn(news, ...

  10. Error:/bin/bash: /bin/java: No such file or directory

    描述:在Hadoop运行Job的时候,可能会报这样的一个错误“/bin/bash: /bin/java: No such file or directory”,那是因可能有些地方用到了/bin/jav ...