【发布时间】:2013-07-15 15:20:56
【问题描述】:
我已使用此代码在另一个之上显示 2 个列表视图。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#f00" >
</ListView>
<ListView
android:id="@+id/listView2"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#0f0" >
</ListView>
问题在于,这会导致 2 个列表视图分别占据屏幕的一半。 我正在向这两个列表添加标题。
LevelAdapter adapter = new LevelAdapter(getActivity(),
R.layout.list_item, weather_data);
View header = inflater.inflate(R.layout.header2, null);
View header2 = inflater.inflate(R.layout.header, null);
lv1.addHeaderView(header);
lv2.addHeaderView(header2);
lv1.setAdapter(adapter);
lv2.setAdapter(adapter);
我希望在第一个列表结束后显示第二个列表的标题。我该怎么做?如何使列表视图出现,以便第二个在第一个结束时开始? 谢谢
【问题讨论】:
标签: android listview android-layout-weight