博观而约取,厚积而薄发。这篇文章主要讲述The method Inflate() in android相关的知识,希望能为你提供帮助。
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.
【The method Inflate() in android】
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
推荐阅读
- android运行时异常:Binary XML file line # : Error inflating class
- Windows 11/10如何修复“文件资源管理器无响应”(9大方法)
- Ionic按钮
- Ionic警告框
- Ionic和AdMob集成
- Ionic上拉菜单
- Ionic 4和Ionic 3之间的区别
- Ionic教程介绍
- IntelliJ Idea和Eclipse之间的区别