可以使用LayoutInflater来获取Layout的xml配置。
1、LayoutInflater有2中方式获得:
<1>、LayoutInflater flater= getLayoutInflater();
<2>、LayoutInflater flater= (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
2、获取Layout:
//R.layout.customer是Layout的xml配置
View layout = flater.inflate(R.layout.customer,null);
3、获取Layout中的组件:
ImageView image = (ImageView) layout.findViewById(R.id.imgview);
本文介绍了如何使用LayoutInflater从XML文件加载布局资源,并展示了两种获取LayoutInflater实例的方法。此外,还提供了具体的代码示例,演示了如何通过inflate方法加载指定的布局资源,并获取其中的组件。
6万+

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



