2011-05-12 94 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"