2014-06-18 12 views
8

Ich bin mein fragment_main.xml in Android Studio bearbeiten, und ich erhalte diese Störung:Mehrere Root-Tags im Android Studio

mehrere Stamm Schlagwörter

Der Codeblock in Frage hier ist:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="horizontal" android:layout_width="match_parent" 
android:layout_height="match_parent"> 

</LinearLayout> 
<EditText <!--Error here in the bracket--> 
android:id="@+id/edit_message" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:hint="@string/edit_message" /> 
<Button <!--Error here in the bracket--> 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="@string/button_send"/> 

ich erhalte die Fehler in den Klammern vor EditText und vor Knopf

+6

setzen Sie den EditText und Button innerhalb des linearen Layouts. –

+0

Nein, ich musste es nur in das lineare Layout bringen! – rakeshdas

Antwort

10

Da in Android jeder XML-Datei muss nur ein Root-Layout sein. Fügen Sie einfach den EditText und den Button innerhalb des LinearLayouts hinzu. Der richtige Code ist unter

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="horizontal" android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<EditText 
android:id="@+id/edit_message" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:hint="@string/edit_message" /> 

<Button  
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="@string/button_send"/> 

</LinearLayout> 
Verwandte Themen