【发布时间】:2012-09-12 20:31:48
【问题描述】:
我正在运行时创建字段,例如在相对布局中,我在右上角添加一个文本字段,在左角添加一个复选框。 对于这个问题,目前我正在使用以下代码:
ViewGroup hori_layout=new RelativeLayout(getParent());
hori_layout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
TextView tv1=new TextView(getParent());
tv1.setText(_medContactNames[i]);
tv1.setTextColor(Color.BLACK);
CheckBox cb = new CheckBox(getApplicationContext());
hori_layout.addView(tv1);
hori_layout.addView(cb);
layout.addView(hori_layout);
【问题讨论】:
-
看到这个它会帮助你[1]:stackoverflow.com/questions/3885077/…
-
非常感谢...我明白了..!!!
-
堆栈溢出总是欢迎你...为我的评论投票