android成长值,常用获取inflate的写法

来源:互联网 发布:大数据培训骗局 编辑:程序博客网 时间:2024/06/08 16:35
//1、context:上下文, resource:要转换成view对象的layout的id, root:将layout用root(ViewGroup)包一层作为codify的返回值,一般传nullview = 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);
0 0
原创粉丝点击