2011-11-26 43 views
0

我正在嘗試爲我的Android設備開發應用程序,而且我似乎遇到了麻煩。我試圖在Activity的頂部有TextView(或另一個組件),並在其下方有Listview。我遇到的問題是,如果我在佈局中使用的不僅僅是ListView,它不會呈現。因此,由於我試圖擁有TextViewListView,因此只顯示TextViewAndroid ListView消失(SDK 2.3.3)

layout.xml

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

    <TextView 
     android:id="@+id/text_view" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/test_string"/> 

    <ListView 
     android:id="@+id/list_view" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:entries="@array/list_contents" > 
    </ListView> 
</LinearLayout> 

我自己也嘗試設置layout_height_wrap\_content_,但它並沒有改變任何東西。

回答

2

添加以下代碼以UR線性佈局

android:orientation="vertical" 
+0

我添加它,現在正在顯示ListView中;但它沒有顯示所有的項目。只有前7個(總共18個)。 – Zymus

+0

您可以使用滾動看到其他項目嗎? –

+0

我可以在Eclipse中的仿真器上看到其他項目,但不能看到設備本身。我也無法在設備上滾動。我試過把ListView放在ScrollView中,但是仍然無法工作。 – Zymus