2011-06-19 22 views
1

我想添加多個listview像一個應用程序的android的twitter:link 但eveytime我嘗試添加多個listview在XML和填充它只是第一個出現。你有解釋嗎?在一個活動中添加多個listview

+0

您可能會將它們放在「LinearLayout」中,其高度設置爲填充父項。嘗試給他們0高度和每個1重量。 – entonio

回答

1

試試這個:

<LinearLayout android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical"> 

<ListView android:id="@+id/list1" 
     android:layout_height="0" 
     android:layout_width="fill_parent" 
     android:layout_weight="1" /> 

<ListView android:id="@+id/list2" 
     android:layout_height="0" 
     android:layout_width="fill_parent" 
     android:layout_weight="1" /> 

</LinearLayout> 

您可以將任意數量的列表視圖中,只要你定義每個的高度爲0和1,重量希望有所幫助。玩的開心!

+0

表示感謝。 – Tsunaze

0

我不知道這個twitter應用程序如何工作,但這可以很容易地使用片段。子類ListFragment,然後在活動中添加儘可能多的片段。

相關問題