LayoutInflater意思是:布局填充器,可以把布局填充成View对象 (1)第一种 view = View.inflate(context, R.layout.item_news_layout, null); context 上下文 resourceId 要加载的布局 ,root :将layout 用viewgroup 包裹起来 ,一般传null
(2)第二种 view = LayoutInflater.from(context).inflate(R.layout.item_news_layout, null); (3)第三种 LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = layoutInflater.inflate(R.layout.item_news_layout, null);
博客介绍了布局填充器LayoutInflater,它可将布局填充成View对象。还给出了三种加载布局的方式,分别是使用View.inflate、LayoutInflater.from(context).inflate以及通过context.getSystemService获取LayoutInflater实例后再调用inflate方法。

被折叠的 条评论
为什么被折叠?



