2012-08-06 41 views
0

我試圖操縱該操作來執行以下操作,但到目前爲止只是導致沮喪...以下是我試圖完成的很糟糕的畫面:如何操縱Android xml中的ListView和佈局

http://i.stack.imgur.com/WZOta.png

http://i.stack.imgur.com/6cEQk.png

<?xml version="1.0" encoding="utf-8"?> 

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 


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


    <ListView 


     android:id="@+id/android:list" 
     android:layout_width="wrap_content" 
     android:layout_height="419dp" > 


    </ListView> 

     <TextView 
      android:id="@+id/android:empty" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/FAP001"    
     /> 
     <Button 
      android:id="@+id/button1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="+1" /> 

</LinearLayout> 
</ScrollView> 

林不知道,如果列表視圖是要走的路..挫折感即時通訊甚至不知道的LinearLayout是一個良好的通話..我試着去有接近最終的結果是什麼在第二張圖片上。 感謝提前!

+0

ListView本身就是一個滾動視圖,所以不應該包含在ScrollView中。從你的草圖中,ListView絕對是正確的方法。 – CSmith 2012-08-06 19:58:00

+0

如果你想要的是每個項目中有幾個「可配置」字段的列表視圖,也許你應該考慮使用listadapter和arrayadapter。檢查這個鏈接。 http://www.vogella.com/articles/AndroidListView/article.html希望是你需要的。 – luanjot 2012-08-06 20:00:16

回答

1

您不能在ScrollView中放置ListView。那是不可能的。因爲那樣ListView有兩個選項可以滾動瀏覽內容,就像你會的那樣。這是行不通的。

欲瞭解更多信息:

https://groups.google.com/forum/m/?fromgroups#!topic/android-beginners/LRpLgGOy2Pc

如果您想擁有帶3「部分」一個ListView我會建議你創建一個自定義適配器自己的自定義的ListView。

這裏是一個自定義的ListView http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/

的爲例,您可以只取這個ListView和只需要修改適配器和行XML自己的需要。