LayoutInflater
2015-12-10 10:12
218 查看
1、对于一个没有被载入或者想要动态载入的界面,都需要使用LayoutInflater.inflate()来载入;
2、对于一个已经载入的界面,就可以使用Activiyt.findViewById()方法来获得其中的界面元素。
inflate 方法 通过 sdk 的 api 文档,可以知道该方法有以下几种过载形式,返回值均是 View 对象,如下:
2、对于一个已经载入的界面,就可以使用Activiyt.findViewById()方法来获得其中的界面元素。
inflate 方法 通过 sdk 的 api 文档,可以知道该方法有以下几种过载形式,返回值均是 View 对象,如下:
public View inflate (int resource, ViewGroup root); public View inflate (XmlPullParser parser, ViewGroup root); public View inflate (XmlPullParser parser, ViewGroup root, boolean attachToRoot); public View inflate (int resource, ViewGroup root, boolean attachToRoot); LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.custom, (ViewGroup)findViewById(R.id.test)); //EditText editText = (EditText)findViewById(R.id.content); // error EditText editText = (EditText)view.findViewById(R.id.content);
相关文章推荐
- CSS3中动画TRANSFORM必须要了解的SKEW变化原理
- 1877: [SDOI2009]晨跑
- swift开发中No such module 'Cocoa' 错误
- Bundle类 android基础一
- hibernate 使用jdbc批量插入数据
- Struts2 Convention Plugin ( struts2 零配置 )
- Mysql通过IP连接授权
- apk系统签名命令
- Mozilla 正式“枪毙”小众手机操作系统火狐 OS
- [SqlHandle] java mysql语法 sql语句拼接工具简类
- SET ANSI_NULLS ON
- iOS自定义NavigationBar
- 2015.12.08-2015.12.11 硕士毕业大论文 前端技术学习
- windos下安装PEAR 注意
- 常用正则表达式
- android:clipToPadding和android:clipChildren
- css sprite demo
- MD5 和 RSA 加密算法理解
- 启动百宝云接口教程
- Java内存与垃圾回收调优