Android:将布局从xml加载到新布局

Android:将布局从xml加载到新布局,android,android-layout,android-linearlayout,Android,Android Layout,Android Linearlayout,我想将xml中定义的布局数据加载到新创建的LinearLayout对象中。可能吗 LinearLayout new_layout = new LinearLayout(context); new_layout.load(R.layout.my_layout); // is something like this possible? 你想要达到的目标通常是这样做的 LayoutInflater inflater = LayoutInflater.from(context); LinearLayo

我想将xml中定义的布局数据加载到新创建的LinearLayout对象中。可能吗

LinearLayout new_layout = new LinearLayout(context);
new_layout.load(R.layout.my_layout); // is something like this possible?

你想要达到的目标通常是这样做的

LayoutInflater inflater = LayoutInflater.from(context);
LinearLayout newLayout = (LinearLayout) inflater.inflate(R.layout.my_layout, null);

你想要达到的目标通常是这样做的

LayoutInflater inflater = LayoutInflater.from(context);
LinearLayout newLayout = (LinearLayout) inflater.inflate(R.layout.my_layout, null);

你想要达到的目标通常是这样做的

LayoutInflater inflater = LayoutInflater.from(context);
LinearLayout newLayout = (LinearLayout) inflater.inflate(R.layout.my_layout, null);

你想要达到的目标通常是这样做的

LayoutInflater inflater = LayoutInflater.from(context);
LinearLayout newLayout = (LinearLayout) inflater.inflate(R.layout.my_layout, null);