2013-11-22 76 views
0

我想将xml中的布局加载到新创建的LinearLayout对象。那可能吗?Android:从xml将布局加载到新布局

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

回答

3

什么你想实现的是平时做这样

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