Drawing on layout

Discussion in 'Introductions' started by rohandvora, Jun 26, 2010.

  1. rohandvora

    rohandvora New Member
    25

    Jun 26, 2010
    3
    0
    25
    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);
    }
    }
    }
     

    Advertisement

  2. Steven58

    Steven58 Reformed PH
    VIP Member
    3,833

    Feb 19, 2010
    32,921
    25,271
    3,833
    Male
    Welcome! Enjoy the forum!

    Sent from my HTC Incredible using Tapatalk Pro
     

Share This Page

Loading...