Reputation: 4550
This is part of my code that must show the table view with several items, but it's not showing anything.
TableLayout tableView = (TableLayout) findViewById(R.id.tableLayoutUsers);
TableRow tr = new TableRow(this);
LayoutParams rowLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
tr.setLayoutParams(rowLayoutParams);
TextView name = new TextView(this);
name.setText(userClass.getUsername());
LayoutParams dateLayParam = new LayoutParams(LayoutParams.WRAP_CONTENT); // , LayoutParams.FILL_PARENT);
name.setLayoutParams(dateLayParam);
tr.addView(name);
tableView.addView(tr, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
tr.setClickable(true);
What's the problem? Thanks
Upvotes: 0
Views: 76
Reputation: 114
Try this code
TableLayout tl = (TableLayout) findViewById(R.id.tableLayoutUsers);
TableRow tr = new TableRow(this);
tr.setId(100 + 0);
TableLayout.LayoutParams params = new TableLayout.LayoutParams(
TableLayout.LayoutParams.WRAP_CONTENT,
TableLayout.LayoutParams.WRAP_CONTENT, 1f);
TextView text = new TextView(this);
text.setText("Meenal");
text.setTextColor(Color.BLACK);
TableRow.LayoutParams imageParams = new TableRow.LayoutParams();
tr.addView(text);
tr.setLayoutParams(params);
tl.addView(tr, params);
Upvotes: 0