Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在线性布局内的放射组中仅允许执行一个radiobtton?_Android_Android Linearlayout - Fatal编程技术网

Android 如何在线性布局内的放射组中仅允许执行一个radiobtton?

Android 如何在线性布局内的放射组中仅允许执行一个radiobtton?,android,android-linearlayout,Android,Android Linearlayout,我试图将一个带有3个单选按钮的单选组放置在一个线性布局中。我的目标是在RadioGroup中只选择一个RadioButton,但这给了我一个错误,即存在多个根标记。有人能想出办法解决这个问题吗 file.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linear

我试图将一个带有3个单选按钮的单选组放置在一个线性布局中。我的目标是在RadioGroup中只选择一个RadioButton,但这给了我一个错误,即存在多个根标记。有人能想出办法解决这个问题吗

file.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="ok"

    android:id="@+id/textemail"/>

<RadioGroup
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<RadioButton
    android:id="@+id/one"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="one" />

<RadioButton
    android:id="@+id/two"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="two"
    />

<RadioButton
    android:id="@+id/three"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="three" />

</RadioGroup>

<TextView
    android:id="@+id/textView1"
    android:layout_below="@+id/textemail"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="To:"
     />

<TextView
    android:id="@+id/TextTo"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="khushi"/>


<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Comment:"
     />

<TextView
    android:id="@+id/TextS3"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="your comment"

    />


<TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="email us "
    android:textAppearance="?android:attr/textAppearanceLarge" />

<EditText
    android:id="@+id/editText"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="top"
    android:inputType="textMultiLine"
    android:lines="10" />

<Button
    android:id="@+id/button"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Send"
    android:textStyle="italic"/>

</LinearLayout>

您可以立即关闭您的团队:

<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent"/>

这应该是:

<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent"> // Note that there is no forward slash at the end
//注意末尾没有正斜杠
您没有关闭
放射组


您立即关闭您的放射组:

<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent"/>

这应该是:

<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent"> // Note that there is no forward slash at the end
//注意末尾没有正斜杠
您没有关闭
放射组

以下更改-

<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<RadioGroup
    android:layout_width="match_parent"
    android:layout_height="match_parent">


您的一个文本格式不正确,请按如下所示进行更改-

<TextView
android:id="@+id/textView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ok:"
 />
以下更改-

<RadioGroup
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<RadioGroup
    android:layout_width="match_parent"
    android:layout_height="match_parent">


您的一个文本格式不正确,请按如下所示进行更改-

<TextView
android:id="@+id/textView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ok:"
 />
您的单选按钮(视图)应该是RadioGroup(视图)的子项。通过使用/>关闭RadioGroup,可以将RadioButton和RadioGroup声明为LinearLayout的子项

以下几点应该行得通

   <?xml version="1.0" encoding="utf-8"?>
<Linearlayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="hello"
    android:id="@+id/textview"/>

<RadioGroup
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<RadioButton
    android:id="@+id/one"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="one" />

<RadioButton
    android:id="@+id/two"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="two"
    />

<RadioButton
    android:id="@+id/three"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="three" />
</RadioButton>
</RadioGroup>

<TextView
    android:id="@+id/textViewllol"
    android:layout_below="@+id/textemail"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="hi:"
     />

<TextView
    android:id="@+id/Texme"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text=""
    />


<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="comment:"
    />

<TextView
    android:id="@+id/Text2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="your comments"

    />


<TextView
    android:id="@+id/textView45"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="ok"
     />

<EditText
    android:id="@+id/editTextMessage"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="top"
    android:lines="10" />

<Button
    android:id="@+id/button4785"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="send"
    />

</LinearLayout>

您的单选按钮(视图)应该是RadioGroup(视图)的子项。通过使用/>关闭RadioGroup,可以将RadioButton和RadioGroup声明为LinearLayout的子项

以下几点应该行得通

   <?xml version="1.0" encoding="utf-8"?>
<Linearlayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="hello"
    android:id="@+id/textview"/>

<RadioGroup
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<RadioButton
    android:id="@+id/one"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="one" />

<RadioButton
    android:id="@+id/two"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="two"
    />

<RadioButton
    android:id="@+id/three"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="three" />
</RadioButton>
</RadioGroup>

<TextView
    android:id="@+id/textViewllol"
    android:layout_below="@+id/textemail"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="hi:"
     />

<TextView
    android:id="@+id/Texme"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text=""
    />


<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="comment:"
    />

<TextView
    android:id="@+id/Text2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="your comments"

    />


<TextView
    android:id="@+id/textView45"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="ok"
     />

<EditText
    android:id="@+id/editTextMessage"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="top"
    android:lines="10" />

<Button
    android:id="@+id/button4785"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="send"
    />

</LinearLayout>

您在
上方有一个
标签,不应该在这里。只需将其移除即可:

<RadioGroup
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<RadioButton
    android:id="@+id/one"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="one" />

<RadioButton
    android:id="@+id/two"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="two"
    />

<RadioButton
    android:id="@+id/three"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="three" />
</RadioGroup>

您在
上方有一个
标签,不应该在这里。只需将其移除即可:

<RadioGroup
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<RadioButton
    android:id="@+id/one"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="one" />

<RadioButton
    android:id="@+id/two"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="two"
    />

<RadioButton
    android:id="@+id/three"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="three" />
</RadioGroup>



RadioButton
应位于
RadioGroup中
未正确声明无线电组!!我修改了上面的代码,但它给了我错误的标签close
RadioButton
应该在
RadioGroup
中,但未正确声明RadioGroup!!我修改了上面的代码,但它给了我错误的关闭标记。我按照你说的更改了代码,但它给了我错误的关闭标记和多个关闭标记。帮帮我,我按你说的做了更改,但它给了我错误的结束标记和多个结束标记。帮帮我。我按照你说的更改了上面的代码,但是它给了我错误的结束标记和多个标记。帮帮我。我看到你添加了
。您应该将
更改为
。在您的情况下,您通过
两次关闭最后一个单选按钮。我重新修改了上面的代码,现在没有错误,但是单选组下面的所有文本视图和编辑视图都消失了。有解决方案吗?您的放射组的
布局\u高度设置为与父组匹配,因此占用了活动上的所有可用空间。更改为wrap_内容,应该是OKi。正如您所说,我更改了上面的代码,但它给了我错误的结束标记和多重标记。帮帮我。我看到你添加了
。您应该将
更改为
。在您的情况下,您通过
两次关闭最后一个单选按钮。我重新修改了上面的代码,现在没有错误,但是单选组下面的所有文本视图和编辑视图都消失了。有解决方案吗?您的放射组的
布局\u高度设置为与父组匹配,因此占用了活动上的所有可用空间。更改为wrap_内容,它应该是OK@khushi:只需移除b4即可。请参阅我的编辑:),它再次给了我相同的错误。这也是线性布局的错误。我重新修改了上面的代码,现在没有错误,但是我的文本视图和编辑视图都消失了。有什么解决办法吗?@khushi:很抱歉没有一次解决你的问题。你需要再修改一个东西,然后就可以了。你能不能请我的朋友,她有个问题,没有人帮助她。这里是链接@khushi:只需删除b4。请参阅我的编辑:),它再次给了我相同的错误。这也是线性布局的错误。我重新修改了上面的代码,现在没有错误,但是我的文本视图和编辑视图都消失了。有什么解决办法吗?@khushi:很抱歉没有一次解决你的问题。你需要再修改一件事,然后就可以了。你能不能请我的朋友,她有问题,没有人帮助她。这是链接