【问题标题】:How to add n number of rows in TableLayout at at runtime in android [duplicate]如何在Android运行时在TableLayout中添加n行[重复]
【发布时间】:2016-09-22 05:27:22
【问题描述】:

我只是需要你的帮助。我想开发一个包含 TableLayout 的应用程序,并且我想在运行时添加 n 行。我试过搜索很多东西,找不到可能的方法。所以任何人都可以提供帮助或提供任何参考..提前感谢

【问题讨论】:

    标签: android android-tablelayout


    【解决方案1】:

    试试这个代码:

    int count=20
        TableLayout tl=(TableLayout)findViewById(R.id.mainLayout); //table layout in xml
                                  for(int i=0;i<count;i++)
                                  {
    
                                      TableRow tr = new TableRow(this);
                                      tr.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
                                      TextView textview = new TextView(this);
                                      textview.setText("hello");
                                      tr.addView(textview);
    
    
                                      tl.addView(tr, new TableLayout.LayoutParams(
                                              LayoutParams.FILL_PARENT,
                                             LayoutParams.WRAP_CONTENT));
                                }
    
    
    
         }
    

    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多