【问题标题】:Tablerow textview above edittext (Android)编辑文本上方的表格行文本视图(Android)
【发布时间】:2014-08-21 22:16:09
【问题描述】:

希望你能帮上忙。所以我需要做的是在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

【问题讨论】:

    标签: android android-edittext textview scrollview tablelayout


    【解决方案1】:

    尝试将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);
    

    希望对你有帮助。

    【讨论】:

    • 如果我想问另一个关于添加内容的问题。我应该提出新问题还是在这里提问?谢谢,我是新手:(
    • @user3793563 如果它与此布局有关,并且是一件小事,请在评论中提问,否则发布新问题。
    • 好吧,我发个新的。一样的问题,但是代码不一样
    猜你喜欢
    • 1970-01-01
    • 2014-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多