1) View view = LayoutInflater.from(context).inflate(要裝載的界面的id, 根節點);//context爲this,根節點一般爲null
view.findViewByID();//與inflate配套使用的。
setContentView();//配套使用findViewByID(動態界面中的控件的id);
2) LayoutInflater inflater = ((Activity)context).getLayoutInflater();
3) 另一種方法獲得
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVER);
view = inflater.inflater (resource, root);
4)view = View.inflate(context, R.layout.header, null);
版權所有,轉載請註明出處!http://blog.csdn.net/kuailebeihun_/article/details/22992685