2012-03-27 16 views
0

ListViewの上に2つのTextViewsを含むRelativeLayoutをヘッダーとして追加しようとしていますが、問題が発生しています。ListViewの上にRelativeLayoutを追加する

<RelativeLayout 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/headerIcon" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
     />   
     <TextView 
      android:id="@+id/headerText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:background="#919191" 
      /> 
      </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/footerIcon" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
     /> 
     <TextView 
      android:id="@+id/footerText" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="right" 
     /> 
    </RelativeLayout>   
    <!-- Footer --> 
    </RelativeLayout> 

UPDATE:

私はそれが部分的に働いてい私がこれまで持っているコードは、リストビュー、フッター、ないヘッダを示しています。次のコードは、TextViewsヘッダーを表示しますが、ListViewをスクロールすると、ヘッダーのレイアウトがちらつき、消えます。なぜAndroidのレイアウトで作業するのがイライラしているのですか?

これはpartically動作するコードです:

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

    <RelativeLayout 
      android:orientation="horizontal" 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      > 

      <TextView 
       android:id="@+id/headerIcon" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:background="#919191" 
      /> 

      <TextView 
       android:id="@+id/headerText" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:background="#919191" 
       /> 
    </RelativeLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     >   
     <ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" /> 

     <TextView android:id="@android:id/empty" 
      style="@style/BaseStyle" 
      android:text="No keywords entered" 
      android:padding="5dp" 
     /> 
    </LinearLayout> 

    <RelativeLayout 
      android:orientation="horizontal" 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      > 
      <TextView 
       android:id="@+id/statusUpdated" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       style="@style/Status" 
       android:layout_alignParentLeft="true" 
       android:background="#919191" 
      /> 

      <TextView 
       android:id="@+id/statusItems" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       style="@style/Status" 
       android:layout_alignParentRight="true" 
       android:background="#919191" 
       /> 
    </RelativeLayout> 

</RelativeLayout> 

答えて

0
<!-- Header --> 
    <RelativeLayout 
     android:orientation="horizontal" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:layout_above="@+id/llayout" 
     > 
    <LinearLayout android:id="@+id/llayout"> 
     <ListView /> 
     <TextView /> 
    </LinearLayout > 

<!-- Footer--> 
    <RelativeLayout 
     android:orientation="horizontal" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:layout_below=="@+id/llayout" 
     /> 
を引き起こす可能性があり
0

あなたのLinearLayoutがfill_parentに設定されているし、あなたの問題

関連する問題