我想将xml中的布局加载到新创建的LinearLayout对象中。这可能吗?
LinearLayout new_layout = new LinearLayout(context);
new_layout.load(R.layout.my_layout); // is something like this possible?
答案 0 :(得分:3)
你想要达到的目的通常是这样做的
LayoutInflater inflater = LayoutInflater.from(context);
LinearLayout newLayout = (LinearLayout) inflater.inflate(R.layout.my_layout, null);