作用:使用而已文件创建视图对象。
创建:1,LayoutInflater inflater = (LayoutInflater)context.getSystemService
Context.LAYOUT_INFLATER_SERVICE);
2,LayoutInflater inflater = Activity.getLayoutInflater();
3,LayoutInflater inflater = LayoutInflater.from(Context);
使用:
View view = (View)inflater.inflate(int resource, ViewGroup root, boolean attachToRoot)
//resource 表示布局文件在R.java中的标识;
//root 表示View的容器
//attachToRoot 表示 是否与父结点绑定,false时代表只使用父结点的LayoutParams.