2010-04-09 73 views
1

我想定製不同項目之間的列表視圖項目空間。我們通常會顯示帶有默認空間的列表項,以便在列表中查看。我想要自定義它們之間的空間差異,以便可以一次將更多的數據顯示在顯示部分的列表中。如何自定義它們之間的列表視圖項目空間?

請給我提供一些解決方案。

謝謝進階 Praween

回答

0

以編程方式改變填充?

+1

@Jim:您應該將該問題添加爲評論,而不是回答 – Macarse 2010-04-10 22:02:02

+0

這是一個答案。 – 2010-04-10 22:21:06

+2

這不是一個答案。這是一個問題。看到那個小「?」事情到底? – gnovice 2010-04-11 01:47:50

0

定義ListView時,您有兩個佈局組件。 您有:

  • ListView控件本身

這種佈局的佈局可以讓你定義顯示什麼時候該列表是空的或填充。請注意0​​和android:id="@+id/android:empty"下面的內容,以便您決定要顯示的內容。這裏的一個示例:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:paddingLeft="8dp" 
     android:paddingRight="8dp"> 

    <ListView android:id="@id/android:list" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:background="#000000" 
       android:layout_weight="1" 
       android:drawSelectorOnTop="false"/> 

    <TextView android:id="@id/android:empty" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:background="#FF0000" 
       android:text="No data"/> 
</LinearLayout> 
  • 每個條目

這種佈局將定義每個條目將如何顯示的佈局。根據我的說法,這是你所感興趣的。例如,如果你想要一個條目中的兩個信息的條目的佈局將類似於這樣:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <TextView android:id="@+id/text1" 
     android:textSize="16sp" 
     android:textColor="#99FFFFFF" 
     android:layout_width="fill_parent" 
     android:layout_height="20px"/> 

    <TextView android:id="@+id/text2" 
     android:textSize="13sp" 
     android:textColor="#FFFFFF" 
     android:layout_width="fill_parent" 
     android:layout_height="20px"/> 
</LinearLayout> 

所以,現在你只需要修改的最後一個例子佈局和管理它,你想要的方式。 希望我能幫上忙,如果您需要更多信息請不要猶豫。

相關問題