Dynamicly added Rows aren't visible
<p>I recently started to play arround with Android. One of the first things I tried to achieve was creating a dynamic TableLayout. Searching the web, I found some sample code at <a href="http://en.androidwiki.com/wiki/Dynamically_adding_rows_to_TableLayout" rel="nofollow">http://en.androidwiki.com/wiki/Dynamically_adding_rows_to_TableLayout</a> which I copied into my activity.</p>

<p>So my Activity now looks like this:</p>

<pre><code>public class FooActivity extends Activity {

  @Override
  protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.foo);

      /* Find Tablelayout defined in main.xml */
      TableLayout tl = (TableLayout)findViewById(R.id.myTableLayout);

      for(int i= 0; i &lt; 9; i++){

           /* Create a new row to be added. */
           TableRow tr = new TableRow(this);
           tr.setLayoutParams(new TableRow.LayoutParams(
                          LayoutParams.FILL_PARENT,
                          LayoutParams.WRAP_CONTENT));
           tr.setBackgroundColor(Color.MAGENTA);

                /* Create a Button to be the row-content. */
                Button b = new Button(this);
                b.setText("Dynamic Button");
                b.setLayoutParams(new LayoutParams(
                          LayoutParams.FILL_PARENT,
                          LayoutParams.WRAP_CONTENT));

                /* Add Button to row. */
                tr.addView(b);

      /* Add row to TableLayout. */
      tl.addView(tr,new TableLayout.LayoutParams(
                LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT));
    }
  }

}
</code></pre>

<p>my foo.xml in the layouts folder looks like this:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/myTableLayout"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
&gt;
 &lt;TableRow
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"&gt;

      &lt;Button android:text="Static Button"/&gt;
 &lt;/TableRow&gt;
&lt;/TableLayout&gt;
</code></pre>

<p>When I now start my app in the emulator, none of the dynamicly added rows are visible. I just see the static button which has been defined in the foo.xml file. With an attached debugger, I've been able to see that my code gets executed and the rows are added to the tablelayout object. However, the added rows aren't rendered.</p>

<p>Any ideas?</p>
