ListView with a ListView header
<p>I have a problem with adding a listview as a header in my listview (go go redundancy). The code is working, however only the first item shows up in the header. The body looks fine.</p>

<pre><code>listView = (ListView) findViewById(R.id.default_list_view);
header = (ListView) getLayoutInflater().inflate(R.layout.savings_overview_header_list, null, false);
HeaderAdapter hAdapter = new HeaderAdapter(getLayoutInflater());

hAdapter.addItem("1");
hAdapter.addItem("2");
hAdapter.addItem("3");

header.setAdapter(hAdapter);    

for (Policy p : saving.getPolicies()) {
    adapter.addItem(p);
}

listView.addHeaderView(header);
listView.setAdapter(adapter);
</code></pre>

<p><strong>headerView:</strong></p>

<pre><code>&lt;ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/default_list_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000"
android:divider="@drawable/list_divider"
android:dividerHeight="2px"
android:fadingEdge="none"
android:fitsSystemWindows="true"
android:footerDividersEnabled="false"
android:headerDividersEnabled="false"
android:listSelector="@drawable/list_item_background_selected" 
&gt;
&lt;/ListView&gt;
</code></pre>

<p>I have tried wrapping the ListView in a vertical LinearLayout but no cigar there either :(</p>

<p><strong>hAdapter</strong></p>

<pre><code>private static class HeaderAdapter extends BaseAdapter {

    private final LayoutInflater inflater;

    protected ArrayList&lt;String&gt; data = new ArrayList&lt;String&gt;();

    public HeaderAdapter(LayoutInflater inflater) {
        this.inflater = inflater;
    }

    public void addItem(String s) {
        data.add(s);
    }

    public View getView(int position, View convertView, ViewGroup parent) {

        final PolicyViewHolder holder;

        if (convertView == null) {
            convertView = inflater.inflate(R.layout.savings_overview_header_item, parent, false);
            holder = new PolicyViewHolder();

            holder.header = (TextView) convertView.findViewById(R.id.list_item_header);
                            holder.subHeader = (TextView) convertView.findViewById(R.id.list_item_subheader);
                            holder.img = (ImageView) convertView.findViewById(R.id.list_item_img);
            convertView.setTag(holder);
        } else {
            holder = (PolicyViewHolder) convertView.getTag();
        }

        String s = data.get(position);

        holder.header.setText(s);
                    holder.subHeader.setText(s);
        holder.img.setImageResId(R.drawable.test);

        return convertView;
    }

    public int getCount() {
        return data.size();
    }

    public Object getItem(int position) {
        return data.get(position);
    }

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

    private static class PolicyViewHolder {
        TextView header;
                    TextView subHeader;
                    ImageView img;
    }
}
</code></pre>

<p><strong>header_item</strong></p>



<pre><code>&lt;RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="10dp"
    android:paddingRight="10dp" &gt;

    &lt;ImageView 
        android:id="@+id/list_item_img"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:src="@drawable/ic_launcher"/&gt;

    &lt;LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="5dp"
        android:layout_toLeftOf="@+id/list_item_value"
        android:layout_toRightOf="@+id/header_image"
        android:orientation="vertical" &gt;

        &lt;TextView
            android:id="@+id/list_item_header"
            style="@style/header_list_header"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" /&gt;

        &lt;TextView
            android:id="@+id/list_item_subheader"
            style="@style/list_header_sub_header"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="sub header" /&gt;
    &lt;/LinearLayout&gt;

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

<p>i have tried to wrap a linearlayout="vertical" around this one as well</p>
