Adding objects to a ListView row at runtime
<p>I am trying to add elements to a ListView dynamically at runtime. Here is my code.</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="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/category_row"
    android:orientation="horizontal" &gt;
    &lt;!-- Contents will be added at Runtime --&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>The getView function overridden by my adapter</p>

<pre><code>@Override
    public View getView(final int position, final View convertView,
            final ViewGroup parent) {
        View searchResultsRow = convertView;
        LinearLayout linearLayout;
        TextView e1,e2,e3,e4;
        if (searchResultsRow == null) {
            LayoutInflater layoutInflator = (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            searchResultsRow = layoutInflator.inflate(
                    R.layout.categories_row_object, null);
            linearLayout = (LinearLayout) searchResultsRow.findViewById(R.id.category_row);

        }
        e1 = new TextView(context);
        e2 = new TextView(context);
        e3 = new TextView(context);
        e4 = new TextView(context);

        e1 = new TextView(context);
        e1.setText("Fashion");
        linearLayout.addView(e1);

        e2 = new TextView(context);
        e2.setText("Men");
        linearLayout.addView(e2);

        e3 = new TextView(context);
        e3.setText("Casual Wear");
        linearLayout.addView(e3);


        e4 = new TextView(context);
        e4.setText("Jeans");
        linearLayout.addView(e4);


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

<p>Now what happens that the first couple of rows seem at jumbled up. Like multiple rows have been added to the same row. What am i doing wrong ? </p>

<p>Kind Regards,</p>
