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

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. [Android(安卓)源码] Android源码下载
  2. Android的内存管理机制
  3. Android中intent传递对象和Bundle的用法
  4. Android(安卓)Studio 快捷键(汇总)
  5. Android(安卓)UI系列-----ImageView的sca
  6. Android(安卓)数据存储(二) 文件的使用
  7. Android内部数据库
  8. Android视频教程分享
  9. Android开发环境(入门)
  10. 最好的Android学习材料