title: Create TableLayout programmatically
body: <p>I'm trying to create a TableLayout programatically. It just won't work. The same layout in an xml file works though. This is what I have:</p>
  
  <pre><code>public class MyTable extends TableLayout
  {
      public MyTable(Context context) {
          super(context);
  
          setLayoutParams(new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
          TableRow row = new TableRow(context);
          row.setLayoutParams(new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
  
          Button b = new Button(getContext());
          b.setText("hello");
          b.setLayoutParams(new LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
          row.addView(b); 
          addView(row)
      }
  }
  
  ...
  
  // In main activity:
  MyTable table = new MyTable(this);
  mainLayout.addView(table);
  </code></pre>
  
  <p>When I run this, I don't get a crash, but nothing appears. If I get rid of the TableRow instance, at least the button does appear as a direct child of the TableLayout. What am I doing wrong?</p>