我希望你能提供帮助。所以我需要做的是在textview下面有一个edittext(在图片中很好地解释了)
(图片)
代码:
for(int x=0 ; x < loopCount; x++){
TableRow.LayoutParams params = new TableRow.LayoutParams( headerCellsWidth[x+1],LayoutParams.MATCH_PARENT);
params.setMargins(0, 0, 0, 0); //left? up? right? down?
TextView tv1=new TextView(getContext());
EditText et1=new EditText(getContext());
et1.setHeight(40);
et1.setWidth(40);
tv1.setText("Text");
TextView textViewB = this.bodyTextView(info[x]);
taleRowForTableD.addView(tv1,params);
taleRowForTableD.addView(et1);
}
我希望你能帮助我:) 这是完整的示例http://www.codeofaninja.com/2013/08/android-scroll-table-fixed-header-column.html
答案 0 :(得分:0)
尝试将EditText
和TextView
保留在RelativeLayout
中,然后将RelativeLayout
放入TableRow
小区。
RelativeLayout layout = new RelativeLayout(this);
TextView tv = new TextView(this);
tv.setText("My text");
EditText et = new EditText(this);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.BELOW, tv.getId());
layout.addView(tv);
layout.addView(et, lp);
taleRowForTableD.addView(layout);
希望它有所帮助。