LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.main,
null
);
LayoutInflater inflater = LayoutInflater.from(context); (该方法实质就是第一种方法,可参考源代码)
View layout = inflater.inflate(R.layout.main,
null
);
LayoutInflater inflater = getLayoutInflater();(在Activity中可以使用,实际上是View子类下window的一个函数)
View layout = inflater.inflate(R.layout.main,
null
);
<Gallery
android:id="@+id/gallery"
android:layout_width="fill_parent"
android:layout_height="110px"
android:layout_alignParentLeft="true"
android:layout_marginTop="10px" >
</Gallery>
<ImageSwitcher
android:id="@+id/imageswitch"
android:layout_width="90px"
android:layout_height="90px"
android:layout_alignBottom="@+id/gallery"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#005599" >
</ImageSwitcher>
LayoutInflater inflater =LayoutInflater.from(this);
//动态加载xml文件生成VIew
View view = inflater.inflate(R.layout.imageswitch,null);
//将View载入对话框
builder.setView(view);
Gallery gallery = (Gallery)view.findViewById(R.id.image_switvher);
inflater 动态载入xml文件生成View,1将View放入对话框,在View中提取组件。
LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.main,
null
);
LayoutInflater inflater = LayoutInflater.from(context); (该方法实质就是第一种方法,可参考源代码)
View layout = inflater.inflate(R.layout.main,
null
);
LayoutInflater inflater = getLayoutInflater();(在Activity中可以使用,实际上是View子类下window的一个函数)
View layout = inflater.inflate(R.layout.main,
null
);