Android数据填充器LayoutInflater

来源:互联网 发布:淘宝在国外 编辑:程序博客网 时间:2024/06/11 03:31

LayoutInflater是用来找res/layout/下的xml布局文件,并且实例化这个XML文件成为一个View,有点类似于类似于findViewById()。对于一个没有被载入或者想要动态载入的界面,都需要使用LayoutInflater.inflate()来载入;对于一个已经载入的界面,使用Activiyt.findViewById()方法来获得其中的界面元素。

LayoutInflater实例方式:

LayoutInflater inflater = LayoutInflater.from(this);
LayoutInflater inflater = getLayoutInflater();
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);


0 0
原创粉丝点击