嗨,我正在尝试将相对视图添加到合并适配器,但它目前正在单独滚动到列表,所以有人知道我如何将带有图像视图和文本视图的相对布局添加到合并适配器?
我的目标是让它看起来像这样
header(relativelyout red bar and title);
List
header(relativelyout red bar and title);
List
header(relativelyout red bar and title);
List
并让这一切滚动,就好像它都是一个列表一样
这是我迄今为止的尝试
arrayAdapter = new ArrayAdapter<String>(this, R.layout.single_item, newsList);
arrayAdapter2 = new ArrayAdapter<String>(this, R.layout.single_item, newsList2);
arrayAdapter3 = new ArrayAdapter<String>(this, R.layout.single_item, newsList3);
ListView list = getListView();
list.setTextFilterEnabled(true);
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE );
View header = inflater.inflate( R.layout.redcell, list, false);
setListAdapter (arrayAdapter);
adapter = new MergeAdapter();
adapter.addView(header);
adapter.addAdapter(arrayAdapter);
adapter.addView(header);
adapter.addAdapter(arrayAdapter2);
adapter.addView(header);
adapter.addAdapter(arrayAdapter3);
setListAdapter(adapter);
}
红细胞.xml
<?xml version="1.0" encoding="utf-8"?>
<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" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="30dp"
android:src="@drawable/titlerect" />
<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"/>
</RelativeLayout>