Setting up a cutom view within a listActivity item from xml
<p>I have a list activity. I would like each item in the list to consist of a text view and three image views. But all the items line up. How do I configure my xml and/or code correctly?</p>

<p>First, just to make sure things were working, when I wrote my ListActivity I wrote my custom ListAdapter with a getView function which returned only a TextView as follows:</p>

<pre><code>public class TA extends ListActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        class custom_adapter implements ListAdapter {

            public int getCount() {
                return 3;
            }

            public Object getItem(int position) {
                return null;
            }

            public long getItemId(int position) {
                return 0;
            }

            public boolean hasStableIds() {
                // TODO Auto-generated method stub
                return false;
            }


            public View getView(int position, View convertView, ViewGroup parent){
                TextView t2View = new TextView(getApplicationContext());
                t2View.setText("some text");
                return t2View;
            }



            public int getItemViewType(int position) {
                // TODO Auto-generated method stub
                return 0;
            }

            public int getViewTypeCount() {
                // TODO Auto-generated method stub
                return 1;
            }

            public boolean isEmpty() {
                // TODO Auto-generated method stub
                return false;
            }

            public boolean areAllItemsEnabled() {
                // TODO Auto-generated method stub
                return false;
            }

            public boolean isEnabled(int position) {
                // TODO Auto-generated method stub
                return false;
            }

            public void registerDataSetObserver(DataSetObserver observer) {
                // TODO Auto-generated method stub

            }

            public void unregisterDataSetObserver(DataSetObserver observer) {
                // TODO Auto-generated method stub

            }

        }

        this.setListAdapter(new custom_adapter());

    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {

    }
}
</code></pre>

<p>And this worked fine. Then I tried to fill my list with a more complex view</p>

<pre><code>public View getView(int position, View convertView, ViewGroup parent) {


            LayoutInflater inflater = getLayoutInflater();
            View layout = inflater.inflate(R.layout.tt_layout, (ViewGroup) findViewById(R.id.tt_root));

            TextView tView = (TextView) layout.findViewById(R.id.tt);

            switch(position){
            case 0:tView.setText("Pos0");break;
            case 1:tView.setText("Pos1");break;
            case 2:tView.setText("Pos2");break;
            case 3:tView.setText("Pos3");break;
            }

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

<p>Using this 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:id="@+id/tt_root"
              android:orientation="horizontal"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:padding="10dp"
              android:background="#DAAA"
              android:weightSum="1"&gt;
    &lt;TextView android:layout_height="wrap_content" android:id="@+id/tt" android:layout_width="wrap_content" android:text="Some text" android:textAppearance="?android:attr/textAppearanceLarge"&gt;&lt;/TextView&gt;
    &lt;ImageButton  android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/ImageButton&gt;
    &lt;ImageButton android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt;&lt;/ImageButton&gt; 
    &lt;ImageButton android:id="@+id/button3" android:layout_height="wrap_content" android:layout_width="wrap_content"&gt;&lt;/ImageButton&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>But instead of the correct behavior all of the items stack next to each other and not as seperate list items.</p>
