Tablerow textview上面的edittext(Android)

时间:2014-07-01 11:10:52

标签: android android-edittext textview scrollview tablelayout

我希望你能提供帮助。所以我需要做的是在textview下面有一个edittext(在图片中很好地解释了)

(图片) http://www.upload.ee/image/4134038/Untitled.png

代码:

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

1 个答案:

答案 0 :(得分:0)

尝试将EditTextTextView保留在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);

希望它有所帮助。