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. 4.flask数据库

    1.安装MySQL 直接去下载即可,如果是windows建可以下载msi,一路next即可.我已经安装过了,这里就不再演示了. 最后使用Navicat连接测试一下,我这里是没有问题的 2.SQLAlc ...

  2. [ nginx ] 带宽下载限速

    nginx上了一个APP提供给用户下载,考虑到带宽占用的问题,决定在nginx上做下载限速处理. 操作系统:Centos6.7 X64 nginx版本:nginx/1.11.3 根据官方文档: 对ng ...

  3. C# for Hbase 实现详解

    一共两种方式访问 通过Thrift访问 目前hbase src.tar.gz压缩包中包含thrift he thrift2; 根据官方文档,thrift可能被抛弃,但是网上基本上都是介绍thrift的 ...

  4. 堆外内存: Chronicle Map

    https://www.javacodegeeks.com/2015/04/chroniclemap-java-architecture-with-off-heap-memory.html Java堆 ...

  5. k8s的回滚应用

    kubectl apply 每次更新应用时 Kubernetes 都会记录下当前的配置,保存为一个 revision(版次),这样就可以回滚到某个特定 revision. 默认配置下,Kubernet ...

  6. 解决 org.aspectj.weaver.ResolvedType$Array cannot be cast to org.aspectj.weaver.ReferenceType

    参考:http://www.cnblogs.com/qgc88/p/3283217.html 解决方法: 删除aspectjweaver.jar和aspect.jar 加入aspectjweaver- ...

  7. shell字符串变量的特异功能:字符串的替换(${str/源模式/目标模式},${str//源模式/目标模式})、截断

    https://blog.csdn.net/wzb56_earl/article/details/6953612

  8. The number of steps(概率dp)

    Description Mary stands in a strange maze, the maze looks like a triangle(the first layer have one r ...

  9. uva11168

    uva11168 题意 给出一些点坐标,选定一条直线,所有点在直线一侧(或直线上),使得所有点到直线的距离平均值最小. 分析 显然直线一定会经过某两点(或一点),又要求点在直线某一侧,可以直接求出凸包 ...

  10. hdu6049

    hdu6049 题意 给出一串由 \([1, n]\) 组成的 \(n\) 个数,每个数字都不相同.现在要尽可能的分成多个块,每个块内的数可以任意排序,且分完块后可以交换两个块的位置,问使得最后序列有 ...