常用获取inflate的写法
1.
//context:上下文, resource:要转换成view对象的layout的id, root:将layout用root(ViewGroup)包一层作为codify的返回值,一般传null
//view = View.inflate(context, R.layout.item_news_layout, null);//将一个布局文件转换成一个view对象
2.
//通过LayoutInflater将布局转换成view对象
//view = LayoutInflater.from(context).inflate(R.layout.item_news_layout, null);
3.
//通过context获取系统服务得到一个LayoutInflater,通过LayoutInflater将一个布局转换为view对象
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = layoutInflater.inflate(R.layout.item_news_layout, null);
转载于:https://www.cnblogs.com/xufengyuan/p/5768133.html
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
