2012-03-27 3 views
0

Android 레이아웃 작업의 경우 모두 엄지 손가락입니다. ListView가 있고 ListView 위와 아래에 TextView를 추가해야합니다.위와 아래의보기 추가 ListView

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <!-- Header --> 
    <RelativeLayout 
     android:orientation="horizontal" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     > 
     <TextView 
      android:id="@+id/header" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
     />   
    </RelativeLayout> 
    <!-- Header --> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:padding="0dp"  
     >   
      <ListView 
       android:id="@android:id/list" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
      /> 

      <TextView android:id="@android:id/empty" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:text="No items" 
       android:padding="5dp" 
       /> 
    </LinearLayout> 

    <!-- Footer --> 
    <RelativeLayout 
     android:orientation="horizontal" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     > 
     <TextView 
      android:id="@+id/footer" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
     /> 
    </RelativeLayout>   
    <!-- Footer --> 
    </LinearLayout> 

답변

2

코드에서, 당신은 addHeaderViewaddFooterView리스트 뷰 자체에 의견을 추가 할 수 있습니다 : 이것은 내가 지금까지있는 것입니다. XML에서는 일종의 레이아웃을 사용해야한다. LinearLayout은 다음을 수행합니다.

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

    <TextView 
     android:id="@+id/header" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     />   

    <ListView 
     android:id="@android:id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     /> 
    <TextView android:id="@android:id/empty" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:text="No items" 
     android:padding="5dp" 
     /> 

    <TextView 
     android:id="@+id/footer" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     /> 
</LinearLayout> 
관련 문제