I\'m trying to make a 3-column TableLayout but I never see anything. Here\'s my java code:
TableLayout tl = (TableLayout)findViewById(R
Try like this:
TableLayout tblLayout = (TableLayout)findViewById(R.id.tableLayout1);
TableLayout.LayoutParams layoutParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT);
TableRow row = new TableRow(this);
row.setBackgroundColor(Color.DKGRAY);
tblLayout.addView(row, layoutParams);
addToTableRow("Name", row, Color.WHITE);
addToTableRow("Age", row, Color.WHITE);
addToTableRow("Location", row, Color.WHITE);
}
private void addToTableRow(String str, TableRow row,int color)
{
TextView t = new TextView(this);
t.setTextColor(color);
t.setText(str);
row.addView(t);
}