您的位置:首页 > 移动开发 > Android开发

Android Studio LayoutInflater介绍

2017-10-28 14:50 267 查看
自定义控件 LayoutInflater

控件就是Button、Image、 ImageButton之类的东西

LayoutInflater 所谓“扩展”,

作用类似于findViewById(),

不同的是LayoutInflater是用来获得View的,

即返回值就是View ,

而findViewById()是用来获得具体控件的

如:

View itemview

= LayoutInflater.from(context).inflate(布局文件中的控件id, parent, false);

用法

第 一种

View itemview = LayoutInflater.from(context).inflate(layoutid, parent, false);


第二种

View itemview = LayoutInflater.from(context).inflate(layoutid, parent, false);


第三种

View itemview = LayoutInflater.from(context).inflate(layoutid, parent, false);


代码摘自http://blog.csdn.net/zuolongsnail/article/details/6370035
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: