LayoutInflater.from(this) View.inflate()
来源:互联网 发布:淘宝买家信誉等级表 编辑:程序博客网 时间:2024/05/20 21:43
原文:http://lzy3169421.blog.163.com/blog/static/113545277201111392857802/
通俗的说,inflate就相当于将一个xml中定义的布局找出来.
因为在一个Activity里如果直接用findViewById()的话,对应的是setConentView()的那个layout里的组件.
因此如果你的Activity里如果用到别的layout,比如对话框上的layout,你还要设置对话框上的layout里的组件(像图片ImageView,文字TextView)上的内容,你就必须用inflate()先将对话框上的layout找出来,然后再用这个layout对象去找到它上面的组件,如:
View view = View.inflate(this, R.layout.dialog_layout, null);TextView dialogTV = (TextView) view.findViewById(R.id.dialog_tv);dialogTV.setText("abcd");
如果组件R.id.dialog_tv是对话框上的组件,而你直接用this.findViewById(R.id.dialog_tv)肯定会报错.
View.inflate()是一样的,更简单一些.
- LayoutInflater.from(this) View.inflate()
- LayoutInflater.from(this) View.inflate()
- LayoutInflater.from(this)、inflate 详解
- View.Inflate)与LayoutInflater.from().inflate();
- LayoutInflater.from(this).inflate()参数解析
- View.inflate() 和 LayoutInflater.from(context).inflate()区别
- View.inflate()与LayoutInflater.inflate()的区别?
- LayoutInflater.inflate方法加载View
- android程序 在View view = LayoutInflater.from(getContext()).inflate(resourceId, nul
- 自定义组合控件关于LayoutInflater.from(context).inflate(R.layout.view_title, this,true)的问题
- 关于LayoutInflater.from().inflate()方法不能加载自定义view的解决办法
- 源码分析初级《篇一》 为何建议使用LayoutInflater.from而不用View.inflate
- LayoutInflater.from(this)
- 布局填充器:LayoutInflater View.inflate
- View.inflate和LayoutInflater的inflate方法区别
- (转)View.inflate和LayoutInflater的inflate方法区别
- View inflate 方法与 LayoutInflater inflate 方法的区别详解
- LayoutInflater.from(this)的用法--inflate就相当于将一个xml中定义的布局找出来.
- 应用决定产品
- Write a C program to find the parity of an unsigned integer
- linux uname命令参数及用法详解--linux查看系统信息命令
- word粘贴至html特殊字符 粘贴后可能为乱码
- 程序员面试题--奇虎360
- LayoutInflater.from(this) View.inflate()
- 客户管理案例
- Ubuntu13.04 显示隐藏文件和文件夹
- 【explorer崩溃】手动修复指南
- Java中单例模式的几种正确实现方法
- Redhat5.4 安装wireshark
- 在用MKMapView self.mapView.showsUserLocation = YES; 实现定位时不能打开飞行模式
- 网上看到的IQ题
- 享元模式