Android merge adapter adding a view from an xml
<p>hi i'm trying to add a view to a merge adapter and i'm not entirely sure as to how to do. i'm wanting to add a header bar in between two lists. so far i have3 arrayadapters that populate one list im wanting to add a header between each one. i have a .xml layout that i want to use for the header or would it be better to programmatically write the layout.</p>

<p>heres my as to what i have tried so far but keep getting errors when i scroll it crashes the app. hopefully i have made this clear enough as  i think its really useful to learn this.</p>

<pre><code>arrayAdapter = new ArrayAdapter&lt;String&gt;(this, R.layout.single_item, newsList);
    arrayAdapter2 = new ArrayAdapter&lt;String&gt;(this, R.layout.single_item, newsList2);
    arrayAdapter3 = new ArrayAdapter&lt;String&gt;(this, R.layout.single_item, newsList3);


     RelativeLayout layout = new RelativeLayout(this);
        RelativeLayout.LayoutParams labelLayoutParams = new RelativeLayout.LayoutParams(
                LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
        layout.setLayoutParams(labelLayoutParams);

        ImageView mImage = new ImageView(this);
        mImage.setBackgroundResource(R.drawable.titlerect);        
        //layout.addView(mImage,labelLayoutParams);





     //RelativeLayout rc = (RelativeLayout) findViewById(R.id.redcelllayout);
    LayoutInflater inflater = 
                   (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     View Header = inflater.inflate(R.layout.redcell, layout, true);



    setListAdapter (arrayAdapter);

       ListView list = getListView();
       list.setTextFilterEnabled(true);

        adapter = new MergeAdapter();
        adapter.addAdapter(arrayAdapter);
        adapter.addView(mImage);
        adapter.addAdapter(arrayAdapter2);

        adapter.addAdapter(arrayAdapter3);
        setListAdapter(adapter);

    }   
</code></pre>

<p>and heres the xml layout for the header bar</p>

<pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
     android:id="@+id/redcelllayout" &gt;



    &lt;ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:src="@drawable/titlerect" /&gt;

    &lt;TextView
        android:id="@+id/redheadertext"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:gravity="left"
        android:paddingLeft="15dp"
        android:paddingTop="3dp"
        android:textColor="@color/white"
        android:textSize="15dp"
        android:textStyle="bold"/&gt;
</code></pre>

<p>also heres the error im getting</p>

<pre><code>05-11 09:51:06.187: E/AndroidRuntime(8598): java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams
05-11 09:51:06.187: E/AndroidRuntime(8598):     at android.widget.ListView.setupChild(ListView.java:1834)
05-11 09:51:06.187: E/AndroidRuntime(8598):     at android.widget.ListView.makeAndAddView(ListView.java:1803)
05-11 09:51:06.187: E/AndroidRuntime(8598):     at android.widget.ListView.fillDown(ListView.java:670)
05-11 09:51:06.187: E/AndroidRuntime(8598):     at android.widget.ListView.fillGap(ListView.java:641)
</code></pre>
