How do I correctly format a TableLayout from a Custom ListView Adapter?
<p>Update: I am sorry i pasted in list.xml twice by mistake, my question is now correct!...</p>

<p>I created a class which extends ArrayAdapter, in which I override getView, and in there I capture controls in my row.xml, and setText on them appropiately with my values. This all works fine, I got no problem here.</p>

<p>What I then tried to do is have my output in tabular format, so I can span columns etc and get them all aligned as I wish. Here start my problem.</p>

<p>So I lave my two xml files, one for my list, and one for the row. In the list I define a TableLayout, with nothing in it except my ListView. Not how I set my stretchColumns property? Then in row.xml, I just define a TableRow, so I would expect to get a load of TableRows tags created inbetween the TableLayout start and end tags, and everything will turn out good.</p>

<p>Well it does work in the sense that I can see teh results, HOWEVER all of the TableRows are not aligned with the rest of thd table, or other rows. They just all get sixed to fit there own contents, and seems they are not properly a part of my TableLayout at all.</p>

<p>If I create by hand the xml I would EXPECT to be inflated in my custom adapter, and put it between the TableLayout tags (and remove the ListView) everything displays perfectly, columns aligned etc.</p>

<p>Perhaps I am doing something wrong, or perhaps I should not be using a TableLayout this way and ought to be doing things a different way. </p>

<p>Really appreciate any helps with this, been stuck puzzled on if for ages.</p>

<p>this is row.xml </p>

<p>
</p>

<pre><code>&lt;TableRow
    android:id="@+id/tableRow1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" &gt;

    &lt;TextView
        android:id="@+id/tvQty"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:text="QTY"
        android:textSize="12dp"
        android:textStyle="bold" /&gt;

    &lt;TextView
        android:id="@+id/tvPartName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:paddingLeft="10dip"
        android:text="Part desererregre"
        android:textSize="12dp"
        android:textStyle="bold" /&gt;

    &lt;TextView
        android:id="@+id/tvPartCode"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:paddingLeft="10dip"
        android:text="PART CODE"
        android:textSize="12dp"
        android:textStyle="bold" /&gt;
&lt;/TableRow&gt;
</code></pre>

<p></p>

<p>this is my list.xml </p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" &gt;

    &lt;Button
        android:id="@+id/addCallPart"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="onClick"
        android:text="Button" /&gt;

    &lt;TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="5dip"
        android:paddingRight="5dip"
        android:stretchColumns="1" &gt;

        &lt;ListView
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/hello" /&gt;
    &lt;/TableLayout&gt;

    &lt;TextView
        android:id="@id/android:empty"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:text="There are no records." /&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>here is my code, this all works ok, but i include it to make the question clearer</p>

<pre><code>public class CallPartAdapter extends ArrayAdapter&lt;CallPart&gt; {
    private final Context context;
    private final List&lt;CallPart&gt; values;

    public CallPartAdapter(Context context, List&lt;CallPart&gt; values) {
        super(context, R.layout.row, values);
        this.context = context;
        this.values = values;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView = inflater.inflate(R.layout.row, parent, false);

        TextView textView1 = (TextView) rowView.findViewById(R.id.tvQty);
        TextView textView2 = (TextView) rowView.findViewById(R.id.tvPartName);
        TextView textView3 = (TextView) rowView.findViewById(R.id.tvPartCode);

        textView1.setText(Integer.toString(values.get(position).Qty));
        textView2.setText(values.get(position).PartName);
        textView3.setText(values.get(position).PartCode);       

        return rowView;
    }   
}
</code></pre>
