Hi,
My requirement is like i have to display multiple rows, and each row should contain three buttons as columns.
here is my code :
TableLayout contactLayout;
TableRow tr[] = null;
Button b1 = null;
Button b2 = null;
Button b3 = null;
contactLayout = (TableLayout) findViewById(R.id.ContactsLayout);
for (int i = 0; i < 10; i++) {
b1= new Button(this);
b2 = new Button(this);
b3= new Button(this);
tr = new TableRow(this);
b1.setText("Ramesh");
b2.setText("R@infy.com");
b3.setText("9591504000");
tr.addView(b1, new TableRow.LayoutParams(1));
tr.addView(b2, new TableRow.LayoutParams(2));
tr.addView(b3, new TableRow.LayoutParams(3));
contactLayout.addView(tr, new TableLayout.LayoutParams());
}
But after running the application, i got null pointer exception at tr = new TableRow(this);
Can any one help me to solve this,
If any similar example providing can also be useful to me.
Please Respond.
Ramesh BH
My requirement is like i have to display multiple rows, and each row should contain three buttons as columns.
here is my code :
TableLayout contactLayout;
TableRow tr[] = null;
Button b1 = null;
Button b2 = null;
Button b3 = null;
contactLayout = (TableLayout) findViewById(R.id.ContactsLayout);
for (int i = 0; i < 10; i++) {
b1= new Button(this);
b2 = new Button(this);
b3= new Button(this);
tr = new TableRow(this);
b1.setText("Ramesh");
b2.setText("R@infy.com");
b3.setText("9591504000");
tr.addView(b1, new TableRow.LayoutParams(1));
tr.addView(b2, new TableRow.LayoutParams(2));
tr.addView(b3, new TableRow.LayoutParams(3));
contactLayout.addView(tr, new TableLayout.LayoutParams());
}
But after running the application, i got null pointer exception at tr = new TableRow(this);
Can any one help me to solve this,
If any similar example providing can also be useful to me.
Please Respond.
Ramesh BH