I need to create six textview dynamically in but one condition each table row have only three textview for mine i need to place two table row and place three textview each please
Asked
Active
Viewed 194 times
-6
-
1I will give answer but one condition you need to do it first. – Padma Kumar Aug 07 '12 at 07:24
-
1When did SO became order placement site? – Andro Selva Aug 07 '12 at 07:27
1 Answers
0
Try something like this.
TableLayout myTable=new TableLayout(this);
TextView[][] myTextView=new TextView[3][3];
myTable.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
TableRow[] myRow=new TableRow[3];
for (int i = 0; i < 3; i++) {
myRow[i]=new TableRow(this);
myRow[i].setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
for (int j = 0; j < 3; j++) {
myTextView[i][j]=new TextView(this);
myTextView[i][j].setText("Your Text");
myRow[i].addView(myTextView[i][j]);
}
myTable.addView(myRow[i]);
}
LinearLayout lin=(LinearLayout)findViewById(R.id.linLayout);
lin.addView(myTable);

Rahmathullah M
- 2,676
- 2
- 27
- 44