话说xml布局就是view?不理解:
三种方式可以生成LayoutInflater:
LayoutInflater inflater=LayoutInflater.from(this); LayoutInflater inflater=getLayoutInflater(); LayoutInflater inflater=(LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
然后调用inflate方法将xml布局文件转成View
public View inflate(intresource,ViewGrouproot,booleanattachToRoot) //在View类中,也有inflate方法 public static View inflate(Contextcontext,intresource,ViewGrouproot)