Android動態加載頁面的幾種方法

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



發佈了25 篇原創文章 · 獲贊 0 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章