0
点赞
收藏
分享

微信扫一扫

android中获取布局文件的三种方法


android中获取布局文件的三种方法

R.layout.item 为定义的布局文件(通过一个打气筒把布局文件转换成一个view)

第一种:

view = View.inflate(getApplicationContext(), R.layout.item, null);

第二种:

LayoutInflater inflater = LayoutInflater.from(getApplicationContext());

view = inflater.inflate(R.layout.item, null);

第三种:

LayoutInflater  inflater  =  getSystemService(LAYOUT_INFLATER_SERVICE);

view  =  inflater.inflate(R.layout.item, null);

举报

相关推荐

0 条评论