没有合适的资源?快使用搜索试试~ 我知道了~
LayoutInflater的使用
需积分: 0 1 下载量 146 浏览量
2012-09-11
22:07:24
上传
评论
收藏 19KB DOCX 举报
温馨提示
试读
3页
关于Android的LayoutInflater的使用!
资源推荐
资源详情
资源评论
Android LayoutInater 的用法
1:下面是官方给的注释的部分内容:
/**
* This class is used to instantiate layout XML file into its
corresponding View
* objects. It is never be used directly -- use
* {@link android.app.Activity#getLayoutInflater()} or
* {@link Context#getSystemService} to retrieve a standard
LayoutInflater instance
* that is already hooked up to the current context and correctly
configured
* for the device you are running on. For example:
* <pre>LayoutInflater inflater =
(LayoutInflater)context.getSystemService
* Context.LAYOUT_INFLATER_SERVICE);</pre>
* For performance reasons, view inflation relies heavily on pre-
processing of
* XML files that is done at build time. Therefore, it is not
currently possible
* to use LayoutInflater with an XmlPullParser over a plain XML file
at runtime;
* it only works with an XmlPullParser returned from a compiled
resource
* (R.<em>something</em> file.)
*
* @see Context#getSystemService
*/
上面是官方给出的解释,我在这里稍微翻译下,由于英语水平有限,错误的地方希望大家
给予指正!
1) 该类主要用来实例化 xml 布局文件。他从来不被直接应用的,一般是通过当前
Activity.getLayoutInflater 或者 Context 的 getSystemService 方法来得到一个
layoutInflater 实例,其实这个实例已经存在你的当前上下文和配置到你正在运行的设备
中。
举个例子:可以通过这种方式获取 LayoutInflater 的对象
LayoutInflater inflater =
(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERV
ICE);
资源评论
牛八少爷
- 粉丝: 350
- 资源: 35
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功