2012-06-11 30 views
1

我想用在每個選項卡不止一個CheckBox,但只有一個框顯示了在該選項卡,即使我有三個的LinearLayout下。這種佈局或它的父佈局可能是無用的(機器人)

予設定的ID爲每個複選框也。

以下是正在使用的代碼。

main.xml中

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <TabWidget 
     android:id="@android:id/tabs" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" /> 

    <FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 

     <LinearLayout 
      android:id="@+id/widget43" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      > 

      <CheckBox 
       android:id="@+id/root" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:text="Tortillas" /> 

      <CheckBox 
       android:id="@+id/root1" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:text="Tortillas1" /> 

      <CheckBox 
       android:id="@+id/roo2" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:text="Tortillas2" /> 

     </LinearLayout> 

    </FrameLayout> 

</TabHost> 
+1

後的線性佈局這究竟是怎麼編? LinearLayout沒有高度屬性。 –

+0

@ZedScio是我做錯的唯一事情嗎?謝謝。 –

+0

標籤中只顯示一個複選框? –

回答

0

除了@Barak,你缺少TabHost

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 

     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" > 

      <LinearLayout 
       android:id="@+id/widget43" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:orientation="vertical" > 

       <CheckBox 
        android:id="@+id/root" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Tortillas" /> 

       <CheckBox 
        android:id="@+id/root1" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Tortillas1" /> 

       <CheckBox 
        android:id="@+id/roo2" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Tortillas2" /> 
      </LinearLayout> 
     </FrameLayout> 
    </LinearLayout> 

</TabHost> 
+0

Yoah。偉大的傢伙! –

0

我認爲你需要改變複選框的寬度和高度,以 「WRAP_CONTENT」 而不是 「FILL_PARENT」。第一個填滿父母,剩下的事情就沒有了。

編輯

更改heightof的LinearLayout中,以WRAP_CONTENT以及(看一些我自己的,這就是我如何讓他們成立)。

+0

我這樣做了,但是複選框出現在選項卡的頂部。 –

+0

喜歡它重疊吧@Barack –