我的情況是這樣的:的Android的ListView並沒有擴張按計劃
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:background="#ffffeb">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp">
// Other stuff in between here..
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="12dp"
android:paddingRight="12dp">
<Button
android:id="@+id/insert_ad_ad_information_category_and_type_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="@string/insert_ad_ad_information_category_and_type_button"/>
<ListView
android:id="@+id/insert_ad_ad_information_parameters_frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffeb"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:dividerHeight="0dp"
android:scrollbars="none"
android:listSelector="@android:color/transparent"/>
我的問題是,我不能讓我的ListView
得到我想要的合適的高度。
我將添加幾個組件與我自定義的BaseAdapter
類,並按照預期工作。
但是,當我然後調試我的應用程序時,我只能看到列表中的3個組件中的1.5個,其餘的在ListView
中進一步隱藏。
但我怎樣才能讓我的ListView
計算我有多少組件,並讓它直接顯示所有組件,而不必向下滾動?
另一個想法是,如果我可以使用我的BaseAdapter
填充任何其他類型的視圖?因爲我使用ListView
的唯一原因是因爲setAdapter()
方法。
感謝所有的想法和意見:)
好的,謝謝。我可以如何解決我的問題的任何建議?我可以將BaseAdapter添加到另一種類型的視圖嗎? – 2010-09-09 12:46:52
使用addHeader(View)&addFooter(View)給ListView,然後給它分配適配器(在內部它將標題,光標,頁腳包裝到一個新光標中) – 2010-09-10 02:57:28
太好了。它像一個魅力! :D再次感謝。 – 2010-09-10 09:30:42