【6.13】利用LayoutInflater兑现Layout的切换

【6.13】利用LayoutInflater实现Layout的切换?主要是利用LayoutInflater的inflate方法?相当于findViewById,

【6.13】利用LayoutInflater实现Layout的切换

?

主要是利用LayoutInflater的inflate方法

?

相当于findViewById,只不过查找的是layout的资源

?

LayoutInflater mLayoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

linearLayout1 = (LinearLayout) mLayoutInflater.inflate(R.layout.main, null);

linearLayout2 = (LinearLayout) mLayoutInflater.inflate(R.layout.main2, null);

?

再通过检测动作,执行setContentView(layout),可以完成切换