LayoutInflater的使用
来源:互联网 发布:centos 6.5 分区方案 编辑:程序博客网 时间:2024/05/20 08:01
LayoutInflater的使用
在实际工作中,事先写好的布局文件往往不能满足我们的需求,有时会根据情况在代码中自定义控件,这就需要用到LayoutInflater。
LayoutInflater在Android中是“扩展”的意思,作用类似于findViewById(),不同的是LayoutInflater是用来获得布局文件对象的,而
findViewById()是用来获得具体控件的。LayoutInflater经常在BaseAdapter的getView方法中用到,用来获取整个View并返回。
LayoutInflater的用法有三种:
第一种方法:
LayoutInflater inflater =LayoutInflater.from(this);
View layout =inflater.inflate(R.layout.main, null);
第二种方法:
LayoutInflaterinflater = getLayoutInflater( );
View layout =inflater.inflate(R.layout.mian,null);
第三种方法
LayoutInflater inflater=(LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.main,null);
0 0
- LayoutInflater---LayoutInflater的使用
- 【LayoutInflater】Android 中LayoutInflater的使用!
- LayoutInflater的使用,inflate
- LayoutInflater的使用
- android LayoutInflater的使用
- LayoutInflater的使用
- LayoutInflater 的使用
- Android - LayoutInflater 的使用
- LayoutInflater的使用
- LayoutInflater的使用,inflate
- LAYOUTINFLATER的使用
- LAYOUTINFLATER的使用
- LayoutInflater的使用
- LayoutInflater的使用
- LayoutInflater的使用
- LayoutInflater的使用
- LayoutInflater的使用
- LayoutInflater的使用,inflate
- js获取当前页地址栏完整URL
- Activity之间的数据传递
- 完全手动建立maven骨架
- 网络发送参数拼接与Http异步任务回调打包(二)
- 第十三篇 : (State)状态模式
- LayoutInflater的使用
- Linux正则表达式和通配符的区别
- eclipse m2eclipse 最新下载地址
- java 遍历Map的四种方法
- 在tomcat上面安装solr4.8.0全过程
- solr4.8 DataImportHandler 从关系型数据库导入数据
- tomcat虚拟目录安装及其配置
- solr suggest检查建议
- Android启动画面实现