【发布时间】:2016-09-22 05:27:22
【问题描述】:
我只是需要你的帮助。我想开发一个包含 TableLayout 的应用程序,并且我想在运行时添加 n 行。我试过搜索很多东西,找不到可能的方法。所以任何人都可以提供帮助或提供任何参考..提前感谢
【问题讨论】:
标签: android android-tablelayout
我只是需要你的帮助。我想开发一个包含 TableLayout 的应用程序,并且我想在运行时添加 n 行。我试过搜索很多东西,找不到可能的方法。所以任何人都可以提供帮助或提供任何参考..提前感谢
【问题讨论】:
标签: android android-tablelayout
试试这个代码:
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));
}
}
谢谢
【讨论】: