当前位置: 首页 > 面试题库 >

Android Studio中有多个根标签

侯涵煦
2023-03-14
问题内容

我正在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>


 类似资料:
  • 问题内容: 希望这是一个非常简单的问题。我有一个makefile模式规则,如下所示: 我希望makefile生成许多.so文件,因此我尝试通过执行以下操作来使其生成两个文件(radgrd_py.so和lodiso_py.so): 然后尝试这个: 但是在每种情况下,它只会构建我指定的第一个目标。如果我运行’make radgrd_py.so’可以正常工作,我只是不确定如何指定需要构建的文件列表,这样

  • 我试图将多个存根组合到一个JSON文件中。 我已经准备好阅读这篇文章:加载wiremock存根文件和这篇文章https://github.com/tomakehurst/wiremock/issues/987https://github.com/tomakehurst/wiremock/issues/987 但我还是做不到。 目前,我有以下课程: 在我的文件夹中,我有: 具有不同存根的文件夹 我想

  • 问题内容: 我需要在JTable标头中包含多个可编辑的行,以便同一标头列可以同时包含JTextField和JButton。 我发现了如何实现可编辑的标题单元以及如何拆分标题单元。但是事实证明,这些方法有些不同,我需要将它们融合为一个。 是否已经开发了多个可编辑的JTable标头行解决方案,所以我不需要重新发明自行车了? 到目前为止,我发现了什么: 可编辑标头行代码,摘自:http : //www.

  • 问题内容: 我正在尝试查询与所有给定标记集匹配的对象。 基本上,我希望用户能够添加越来越多的标签来过滤或“缩小”其搜索结果,就像newegg.com一样。 我的表结构是一个对象表,一个标签表和一个MANY:MANY关系表ObjectsTags。所以我有一个像这样的JOIN查询: 我尝试使用IN子句/条件,如下所示: 但是我了解到,这模拟了一系列OR,因此您向查询中添加的标签越多,得到的结果就越多,

  • 我使用JSChart来创建一个简单的时间图。我没有在他们的文档中找到任何设置时间标签的信息。我只想每天出现一次。最好是在午夜。 现在我每个数据集得到1个日期标签。这太过分了。 示例图像 JS函数初始化图表 PHP调用上面的模板。

  • 问题内容: 在Golang中,JSON结构标记可以使用多个名称吗? 问题答案: 请参阅如何在结构中定义多个名称标签,以了解如何在一个结构字段上定义多个标签。 您也可以使用a 代替您的结构。 或者,您可以在结构中使用这两种类型,并使用make方法将返回正确的模式。