The method Inflate() in android
2017-07-31 20:19
141 查看
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:
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.
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 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
- Android开发 Error(建议收藏下来以备不时之需):The number of method references in a .dex file cannot exceed 64K.
- Android开发 Error(建议收藏下来以备不时之需):The number of method references in a .dex file cannot exceed 64K.
- Android开发 Error:The number of method references in a .dex file cannot exceed 64K.
- android错误:The method makeText(Context, CharSequence, int) in the type
- Android开发 Error(建议收藏下来以备不时之需):The number of method references in a .dex file cannot exceed 64K.
- android错误:The method makeText(Context, CharSequence, int) in the type
- 如何处理 android 方法总数超过 65536 . the number of method references in a .dex file exceed 64k
- 如何处理 android 方法总数超过 65536 . the number of method references in a .dex file exceed 64k
- android 的The method makeText(Context, CharSequence, int) in the type Toast is not applicable fo(
- android错误:The method makeText(Context, CharSequence, int) in the type
- 关于android创建对话框报错The method setPositiveButton(int, DialogInterface.OnClickListener) in the type Alert
- 【Android】-- 处理 android 方法总数超过 65536 . the number of method references in a .dex file exceed 64k的两种办法
- android错误:The method makeText(Context, CharSequence, int) in the type
- Android Error - The method replace(int, Fragment) in the type FragmentTransaction is not applicable
- Android “64k”的问题以及解决方案 Error:The number of method references in a .dex file cannot exceed 64K.
- 关于android创建对话框报错The method setPositiveButton(int, DialogInterface.OnClickListener) in the type Alert
- Android Error:The number of method references in a .dex file cannot exceed 64K.
- Caused by: android.view.InflateException: You must specifiy a layout in the include tag: <include la
- android错误:The method makeText(Context, CharSequence, int) in the type