rohandvora
Lurker
I am new to android and am designing a small application.I have to create a Table containing 81(9x9) TextViews.After that I have to draw a vertical line after every 3 elements in the column and a horizontal line after every 3 rows(just like a sudoku grid).The code:
public class App extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TableLayout tl = (TableLayout)findViewById(R.id.TableLayout01);
TableRow[] tr = new TableRow[9];
for(int i=0;i<9;i++)
{
//fill every TableRow object with 9 TextViews
tr=new TableRow(this);
for(int j=0;j<9;j++)
{
TextView tv = new TextView(this);
tv.setText(String.valueOf(i)+","+String.valueOf(j));
tr.addView(tv);
}
tl.addView(tr);
}
}
}
public class App extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TableLayout tl = (TableLayout)findViewById(R.id.TableLayout01);
TableRow[] tr = new TableRow[9];
for(int i=0;i<9;i++)
{
//fill every TableRow object with 9 TextViews
tr=new TableRow(this);
for(int j=0;j<9;j++)
{
TextView tv = new TextView(this);
tv.setText(String.valueOf(i)+","+String.valueOf(j));
tr.addView(tv);
}
tl.addView(tr);
}
}
}