Saturday, 15 January 2011

java - Multiple root tags in Android Studio -



java - Multiple root tags in Android Studio -

this question has reply here:

android xml error parsing xml: junk after document element 2 answers

i edit fragment_main.xml in android studio, , getting error:

multiple root tags

the code block in question here is:

<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 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 bracket--> android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button_send"/>

i getting errors in brackets before edittext , before button

since in android every xml file there must 1 parent layout. add together edittext , button within linearlayout. right code shown below

<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>

java android android-layout android-fragments

No comments:

Post a Comment