我有两个xmls:
LinearLayout
中main_layout
的标识为R.id.customContainer
。
我如何以编程方式<include>
第二次布局(以某种方式使用R.layout.item_layout
?)进入我的customContainer
?
我已经引用ViewGroup customContainer
,但addView
方法接受View
- 我不知道如何创建只有xml布局文件。
答案 0 :(得分:4)
View view = LayoutInflater.from(context).inflate(R.layout.item_layout, customContainer, false);
customContainer.addView(view);