2011-05-12 52 views
0

我有被添加到abc.xml和TextView的ID标签与XML布局具有的问题,多个相对布局正在创建

this.setListAdapter(new ArrayAdapter<String>(this, R.layout.abc,R.id.label, days)); 

以我abc.xml文件我有一个相对的阵列串布局显示导航栏,只需一次。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#4C4646" 
    > 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/RelativeLayout02" android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#3E3D3D" 
    android:paddingRight="3dp" 
    android:paddingLeft="3dp" 
    > 
    <Button android:layout_width="wrap_content" 
     android:layout_height="wrap_content" android:id="@+id/back_listing" 
     android:background="@drawable/android_back_button" 
     android:layout_marginTop="6dp"> 
     </Button> 

<TextView android:id="@+id/search_label" 
    android:layout_width="fill_parent" 
    android:layout_height="45dp" 
    android:layout_toRightOf="@+id/back_listing" 
    android:layout_toLeftOf="@+id/search_submit" 
    android:textSize="20px" 
      android:text="Nav Bar" 
    android:layout_marginTop="7dp" 
    android:layout_marginLeft="45dp" 
    android:layout_gravity="right" 
    android:textStyle="bold"/> 
    /> 


<Button android:layout_width="wrap_content" 
    android:layout_height="wrap_content" android:id="@+id/search_submit" 
    android:layout_alignParentRight="true" 
    android:background="@drawable/android_forward_button" 
    android:layout_marginTop="6dp" 

    > 
</Button> 
</RelativeLayout> 

然后

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:padding="10px" 
android:textSize="15px" 
android:id="@+id/label" 
> 

其与数组列表

但我有问题填充所述的TextView是导航栏示出了在顶部,随后通过我的数组列表中的第一项然后导航栏再次跟随,然后第二个它从我的数组列表然后导航栏,这发生直到数组列表的结尾。同样,导航栏与我的数组列表进行循环。现在,当我离开textview的相对布局(导航栏)的内容时,它显示完美,但当然我希望导航栏在那里显示一次,ontop。

回答

0

你需要单独的:

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:padding="10px" 
android:textSize="15px" 
android:id="@+id/label" 
> 

到不同的XML文件也许叫它row.xml然后用该文件与您的适配器。如果你想要顶部的导航栏,然后把它放在你的主布局中的alignParentTop = true,并通过设置android:layout_below="@+id/navBarLayout"