Friday, 18 May 2012

Dynamically adding rows to TableLayout



@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

/* creating the table layout*/
       
        TableLayout layout = new TableLayout (this);
       
        /* creating the table row*/
        TableRow tr = new TableRow(this);
        /* add row in table*/
       
           TextView b = new TextView (this);
            b.setText("Train No.");     
         b.setTextSize(14.5f);       
         b.setTextColor(Color.YELLOW);
         /* add textview in row*/
         tr.addView(b);


super.setContentView(layout);
}

No comments:

Post a Comment