Inflate() method can find out a layout defined by xml,as like the findViewById() method,but there have some different between them.

The different are:

If your Activity used other layout,such as the dialog layout,and you want to set the component's content in that layout.you must use the inflate() method to find it out,then use the findViewById() method to find other components above it.such as:

View view1=View.inflate(this,R.layout.dialog_layout,null);
  
  TextViewdialogTV=(TextView)view1.findViewById(R.id.dialog_tv);
  
  dialogTV.setText("abcd");

note:R.id.dialog_tv is in dialog layout,if you direct to use the this.findViewById(R.id.diaog_tv),it will throw error.

View viewStub = ((ViewStub) findViewById(R.id.stubView)).inflate();  

you can imagine it as "hidden inflation",hide placed in view,before inflate() just to find the control,but no size and didn't occupy place in the view.

after inflate(),it must have size,but hide.

if you also interest in linux and android embed system,please connection with us in QQ grounp:139761394

The method Inflate() in android的更多相关文章

  1. [原创] Gradle DSL method not found: 'android()' 和 buildToolsVersion is not specified 的解决办法。

    今天在用Android Studio 2.0 打开别人的较早版本生成的工程时, 提示: Gradle DSL method not found: 'android()'. 解决办法为,打开根目录下面的 ...

  2. Gradle DSL method not found: 'android()

    原文错误提示: Error:(16, 0) Gradle DSL method not found: 'android()'Possible causes:<ul><li>Th ...

  3. 【转】解决Gradle DSL method not found: ‘android()’

    [转]解决Gradle DSL method not found: ‘android()’ 最近导入as的项目出了这样的问题 这个问题困扰了我很长时间,好吧,搜了半天全都是runProguard的,最 ...

  4. android studio报错提示: Gradle DSL method not found: 'android() 解决方案

    原文错误提示: Error:(16, 0) Gradle DSL method not found: 'Android()'Possible causes:<ul><li>Th ...

  5. java.lang.RuntimeException: Method setUp in android.test.ApplicationTestCase not mocked. See http://g.co/androidstudio/not-mocked for details.

    解决: build.gradle里加入: android { testOptions { unitTests.returnDefaultValues = true } }

  6. 解决Gradle DSL method not found: ‘android()’

    最近导入as的项目出了这样的问题 这个问题困扰了我很长时间,好吧,搜了半天全都是runProguard的,最后在stackoverflow上搜到解决办法了: http://stackoverflow. ...

  7. 【Android Studio】Gradle DSL method not found:'android()'

    如图所示: 参考:http://www.jianshu.com/p/d370d41fb7da 又遇到了这个问题: 参考:http://stackoverflow.com/questions/24204 ...

  8. [Android]IllegalStateException: Could not find method onBind(View)

    FATAL EXCEPTION: main Process: org.diql.aidldemo, PID: 2274 java.lang.IllegalStateException: Could n ...

  9. [Android ADB] An auto-input method for Android and Windows

    The Valentine's Day is coming. Here is an auto-input method and you may use it to send multiple word ...

随机推荐

  1. HDU 1141 Factstone Benchmark (数学 )

    题目链接 Problem Description Amtel has announced that it will release a 128-bit computer chip by 2010, a ...

  2. 【转】cve2014-3153 漏洞之详细分析与利用

    背景学习: Linux Futex的设计与实现 使用者角度看bionic pthread_mutex和linux futex实现 By kernux TopSec α-lab 一 漏洞概述 这个漏洞是 ...

  3. 入园的第一篇--where、where

    这篇是入园的第一篇随便,后面我会将自己几年前写的博文都转到这里.哎,其实说到博文的事情,我就很郁闷,甚至有些恼火,后面我会详细说说这中间的过程,也许能帮助某些人避免遇到类似的事情.突然想起<西游 ...

  4. xpath用法(持续更新ing)

    article:选取所有article元素的所有子节点 /article:选取根元素article article/a:选取所有属于article的子元素的a元素 //div:选取所有div元素 ar ...

  5. java中final修饰符的使用

    1.final修饰符的用法: final可以修饰变量,被final修饰的变量被赋初始值之后,不能对它重新赋值. final可以修饰方法,被final修饰的方法不能被重写. final可以修饰类,被fi ...

  6. 51nod 几道题

    1001 数组中和等于K的数对 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 给出一个整数K和一个无序数组A,A的元素为N个互不相同的整数, 找出数组A中所有和等于 ...

  7. 取消SecureCRT的右击粘贴功能

    默认为选中时自动复制,右键粘贴 要取消的话在: Options->Global Options ...->Terminal 里面有个Mouse的选项块. Paste on Right/Le ...

  8. 《Java编程思想》笔记 第十五章 泛型

    1 泛型 “泛型”意思就是适用于许多类型. 使用泛型的目的之一: 指定容器持有什么类型,让编译器确保正确性,而不是在运行期发现错误. 这个容器可以看成是有其他类型对象作为成员的类,而不单单只是JDK中 ...

  9. k8s的deployment应用

    Kubernetes 通过各种 Controller 来管理 Pod 的生命周期.为了满足不同业务场景,Kubernetes 开发了 Deployment.ReplicaSet.DaemonSet.S ...

  10. win上配置nginx

    win上配置nginx 网上配置nginx的教程大多都是linux上的,今天贴出来nginx在win上的配置,在此篇配置中,nginx代理了Tomcat以及node服务.配置如下: 注意:根据实际经验 ...