你可以(在垂直LinearLayout
兩個相同大小的列表)創建這樣一個佈局:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@+id/list1"
android:layout_weight="1"
android:layout_height="0dip"
android:layout_width="fill_parent"></ListView>
<ListView
android:id="@+id/list2"
android:layout_weight="1"
android:layout_height="0dip"
android:layout_width="fill_parent"></ListView>
</LinearLayout>
然後你只需要使用他們在你的活動:
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.your_layout);
ListView list1 = (ListView) findViewById(R.id.list1);
list1.setAdapter(...);
ListView list2 = (ListView) findViewById(R.id.list2);
list2.setAdapter(...);
}
也許你可以插入一個這兩個列表之間的彩色線條,因此用戶不會將列表混淆爲單個列表。
爲什麼不把兩個'ListView'放到一個'LinearLayout'中併爲你的活動中的這些列表設置兩個不同的適配器? – Knickedi
這就是我所問的。爲什麼不寫一點關於如何做(可能是一些僞代碼)並將其作爲答案發布? –
你真的想使用兩個列表視圖?它不是一個好的用戶體驗在一個屏幕上有兩個列表視圖 –