2013-01-08 18 views
0

我製作了一個應用程序,用戶可以在其中填寫某些字段中的某些信息。這工作。但是當我想改變佈局時,我有一個問題。 我想要用戶填寫的字段在一個彩色塊(background3)中。所以,我把代碼放在我的XML文件中進行線性佈局,但是當我這樣做時,用戶填寫的所有字段都會消失。有誰知道我做錯了什麼,或者我該如何糾正?當我將它們放入我的XML文件的線性佈局中時,我的文本字段消失

這是我的XML文件的代碼:

<?xml version="1.0" encoding="UTF-8"?> 
    <LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/background" 
    android:orientation="vertical" 
    android:padding="30dip"> 



     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_weight="1" 
      android:layout_height="0dp" 
      android:orientation="vertical" 
      > 
        <include layout="@layout/header"/> 
     </LinearLayout> 

     <LinearLayout 
       xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight="6" 
      android:background="@color/background3" 
      android:orientation="vertical" > 
      <TextView 
       android:id="@+id/button1_label" 
       android:layout_height="fill_parent" 
       android:layout_width="wrap_content" 
       android:text="Voer hieronder je rooster in:" 
       android:textSize="24.5sp" 
       android:layout_gravity="center" 
       android:layout_marginBottom="25dip" /> 

      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="Dag:" 
       android:layout_gravity="center" 
       android:textSize="14.5sp" /> 

      <Spinner 
       android:id="@+id/dag_spinner" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" /> 

      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="Uur:" 
       android:layout_gravity="center" 
       android:textSize="14.5sp" /> 

      <EditText 
       android:id="@+id/uur" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" /> 

      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="Vak:" 
       android:layout_gravity="center" 
       android:textSize="14.5sp" /> 

      <EditText 
       android:id="@+id/vak" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" /> 

      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="Docent:" 
       android:layout_gravity="center" 
       android:textSize="14.5sp" /> 

      <EditText 
       android:id="@+id/docent" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" /> 


      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="Lokaal:" 
       android:layout_gravity="center" 
       android:textSize="14.5sp" /> 

      <EditText 
       android:id="@+id/lokaal" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" /> 

      <LinearLayout 
       android:id="@+id/LinearLayout02" 
       android:orientation="horizontal" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:paddingLeft="20sp"> 

        <Button 
         android:text="Gegevens opslaan" 
         android:id="@+id/Button01add" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="20sp" 
         android:layout_marginLeft="20sp"> 
        </Button> 

        <Button 
         android:text="Terug" 
         android:id="@+id/Button01home" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="20sp" 
         android:layout_marginLeft="20sp">  
        </Button> 

      </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 

回答

0

您的佈局的高度爲0dp,使用wrap_content代替。所以改成這樣:

<LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="6" 
     android:background="@color/background3" 
     android:orientation="vertical" > 

而且你不必申報了Android命名空間中的每一個佈局(在xmlns:android="http://schemas.android.com/apk/res/android"線)

而在你

<TextView 
      android:id="@+id/button1_label" 
      android:layout_height="fill_parent" 
      android:layout_width="wrap_content" 
      android:text="Voer hieronder je rooster in:" 
      android:textSize="24.5sp" 
      android:layout_gravity="center" 
      android:layout_marginBottom="25dip" /> 

有一個25dp底部保證金,儘量減少。

編輯: 和你layout_height設置爲fill_parent,將其設置爲wrap_content

+0

我改變了它,現在只有「在Voer hieronder濟公雞」的影片名稱所示。其餘的仍然錯過... – user1941141

+0

請參閱編輯。也許你的物品沒有足夠的空間。 –

+0

我試過了,但也不起作用。但是,多謝幫助我 – user1941141

相關問題