List View shows objects instead of rows in android
<p>I have a requirement where I have  to generate a list view with each row having an icon and a name. The code looks something like this.</p>

<pre><code>public class MyListActivity extends ListActivity {
...
...

    ArrayList&lt;StringBuilder&gt; categories = new ArrayList&lt;StringBuilder&gt;();
    categories.add(new StringBuilder("xyaq"));
    categories.add(new StringBuilder("wers"));
    categories.add(new StringBuilder("test2"));
    categories.add(new StringBuilder("asfda"));
    categories.add(new StringBuilder("hoyio"));

    ArrayList&lt;RelativeLayout&gt; departments = new ArrayList&lt;RelativeLayout&gt;();

    for (StringBuilder category : categories) {
        RelativeLayout categoryRow = (RelativeLayout) mInflater.inflate(
                R.layout.products_row, null);

        ImageView tempImage = (ImageView) categoryRow.getChildAt(0);
        tempImage.setBackgroundResource(R.drawable.ic_launcher);
        TextView tempTextView = (TextView) categoryRow.getChildAt(1);
        tempTextView.setText(category);
        departments.add(categoryRow);
    }
    ArrayAdapter&lt;RelativeLayout&gt; departmentAdaptor = new ArrayAdapter&lt;RelativeLayout&gt;(
            this, android.R.layout.simple_list_item_1, departments);

    setListAdapter(departmentAdaptor);
}
</code></pre>

<p>and the products_row.xml is as follows:</p>

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

&lt;ImageView
    android:id="@+id/deptIcon"
    android:layout_width="64dp"
    android:layout_height="64dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:background="#FFFFFF"
    android:clickable="false"
    android:contentDescription="@string/hello"
    android:scaleType="fitXY" /&gt;

&lt;TextView
    android:id="@+id/deptName"
    android:layout_width="fill_parent"
    android:layout_height="54dp"
    android:layout_alignLeft="@id/deptIcon"
    android:layout_marginLeft="80dp"
    android:gravity="left|center"
    android:textSize="25dp"
    android:textStyle="bold" /&gt;

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

<p>The problem I am facing is I cannot see the rows with an image and the corresponding text. Instead it shows the list of relative layout objects.</p>
