Can't populate table layout dynamically
<p>I am trying to populate a table dynamically from a ArrayList called orders. The list is getting data from the DB and everything is working except I cant display the data in the table. Below is my Java code.</p>

<pre><code>{
    myprefs=PreferenceManager.getDefaultSharedPreferences(this);
    dba.open();
    orders=dba.pendingOrders(myprefs.getInt("user_id", -1));
    dba.close();
    tableDetails=(TableLayout)findViewById(R.id.tableLayoutforHistory);
    for(int i=0;i&lt;orders.size();i+=3){
        trow=new TableRow(this);
        TVorderId=new TextView(this);
        TVdate=new TextView(this);
        TVtotalBill=new TextView(this);
        totalBill=BigDecimal.valueOf(Double.parseDouble(orders.get(i+2).toString()));
        totalBill = totalBill.setScale(2, BigDecimal.ROUND_HALF_UP);
        createTable(trow, TVorderId, orders.get(i).toString());
        createTable(trow, TVdate, orders.get(i+1).toString());
        createTable(trow, TVtotalBill, String.valueOf(totalBill));
        tableDetails.addView(trow);
    }
    }   
    public void createTable(TableRow tr, TextView t, String viewdata) {
    t.setText(viewdata);
    t.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));
    t.setTextColor(Color.WHITE);
    t.setPadding(20, 0, 0, 0);
    tr.setPadding(10, 11, 10, 11);
    tr.addView(t); // add TextView to row.
}
</code></pre>

<p>Below given is the XML for the same.</p>

<pre><code>&lt;TableLayout
            android:id="@+id/tableLayoutforHistory"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:stretchColumns="*" &gt;

            &lt;TableRow
                android:id="@+id/titleRow"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" &gt;

                &lt;TextView
                    android:id="@+id/TVId"
                    android:layout_width="0px"
                    android:layout_weight="1"
                    android:gravity="left"
                    android:text="OrderId"
                    android:textColor="#FFFFFF"
                    android:textStyle="bold"
                    android:typeface="serif" &gt;
                &lt;/TextView&gt;

                &lt;TextView
                    android:id="@+id/TVDate"
                    android:layout_width="0px"
                    android:layout_weight="3"
                    android:gravity="left"
                    android:text="Date"
                    android:textColor="#FFFFFF"
                    android:textStyle="bold"
                    android:typeface="serif" &gt;
                &lt;/TextView&gt;

                &lt;TextView
                    android:id="@+id/TVBill"
                    android:layout_width="0px"
                    android:layout_weight="1"
                    android:gravity="center_horizontal"
                    android:text="Total Bill"
                    android:textColor="#FFFFFF"
                    android:textStyle="bold"
                    android:typeface="serif" &gt;
                &lt;/TextView&gt;
            &lt;/TableRow&gt;
        &lt;/TableLayout&gt;
</code></pre>
