Drawing on layout


Last Updated:

  1. rohandvora

    rohandvora New Member This Topic's Starter

    Joined:
    Jun 26, 2010
    Messages:
    3
    Likes Received:
    0
    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

    Joined:
    Feb 19, 2010
    Messages:
    32,921
    Likes Received:
    25,271
    Welcome! Enjoy the forum!

    Sent from my HTC Incredible using Tapatalk Pro
     

Share This Page

Loading...