
参见英文答案 > Android XML Error parsing XML: junk after document element 2个
我在AndroID Studio中编辑了fragment_main.xml,我收到此错误:
多个根标签
这里讨论的代码块是:
<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"/>我在EditText之前和button之前的括号中得到错误
解决方法:
因为在AndroID中每个xml文件都必须只有一个根布局.只需在linearLayout中添加EditText和button.正确的代码如下所示
<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 Studio中的多个根标签全部内容,希望文章能够帮你解决java – Android Studio中的多个根标签所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)