如何以编程方式将多个相对布局添加到线性布局。我试过了,但它给了我这个异常“指定的孩子已经有一个父母。你必须调用 removeview()”这是我的代码,
RelativeLayout addlangmid = new RelativeLayout(mActivity);
addlangmid.setBackgroundResource(R.drawable.language_bg_top);
TextView langname = new TextView(mActivity);
LayoutParams params = new LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(20, 0, 30, 30);
langname.setText(str[0]);
addlangmid.addView(langname, params);
fulllay.addView(addlangmid, 0);
RelativeLayout addlangmid1 = new RelativeLayout(mActivity);
addlangmid.setBackgroundResource(R.drawable.language_bg_middle);
TextView langname1 = new TextView(mActivity);
LayoutParams params1 = new LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params1.setMargins(20, 0, 30, 30);
langname1.setText(str[0]);
addlangmid1.addView(langname, params1);
fulllay.addView(addlangmid1, 1);