2014-02-23 2 views
1

두 개의 ListView 위에 TextView가 있어야합니다. 내 XML 코드 :두 개의 ListView 위의 TextView

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:baselineAligned="false" 
    android:orientation="horizontal" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent"> 


<TextView 
    android:id="@+id/statusBar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="Test" /> 

<LinearLayout 
    android:layout_weight="1" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    > 

    <ListView 
     android:id="@+id/leftView" 
     android:layout_height="match_parent" 
     android:layout_width="match_parent"> 
    </ListView> 

</LinearLayout> 


<LinearLayout 
    android:layout_weight="1" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent"> 

    <ListView 
     android:id="@+id/rightView" 
     android:layout_height="match_parent" 
     android:layout_width="match_parent"> 
    </ListView> 

</LinearLayout> 

</LinearLayout> 

TextView를 추가하기 전에는 모든 것이 잘 작동했습니다. 이제 TextView 만 보이고 두 ListView는 더 이상 표시되지 않습니다.

편집 : ListViews를 서로 옆에두고 싶습니다 (하나는 왼쪽, 다른 하나는 오른쪽).

답변

2

변경 수직

android:orientation="vertical" 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:baselineAligned="false" 
android:orientation="vertical" 
android:layout_height="match_parent" 
android:layout_width="match_parent"> 


<TextView 
android:id="@+id/statusBar" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:text="Test" /> 



<LinearLayout 
android:orientation="horizontal" 
android:layout_height="match_parent" 
android:layout_width="match_parent"> 

<ListView 
    android:layout_weight="1" 
    android:id="@+id/rightView" 
    android:layout_height="match_parent" 
    android:layout_width="0dip"> 
</ListView> 

<ListView 
    android:layout_weight="1" 
    android:id="@+id/leftView" 
    android:layout_height="match_parent" 
    android:layout_width="0dip"> 
</ListView> 

</LinearLayout> 

</LinearLayout> 
+0

덕분에 LinearLayout의 방향입니다. 이제 ListView가 표시됩니다. 그러나 하나는 다른 것보다 아래에있다. 나는 그들 중 하나와 다른 권리를 갖고 싶다. –

+0

나는 나의 대답을 편집했다 – Blackbelt

+0

고마워. 그거야. 그러나 경고를받습니다. "중첩 된 가중치는 성능에 좋지 않습니다." –

관련 문제