I just need your help. I want to develop an application which includes TableLayout and also i want to add n number of rows at run time. i have tried searching many stuffs, could'nt find the possible way. So anyone can help or provide any reference.. Thanks in advance
Asked
Active
Viewed 184 times
1 Answers
0
Try this code:
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));
}
}
Thanks

Androider
- 3,833
- 2
- 14
- 24