【问题标题】:Is there any way to create a radio-button Sub-menu?有没有办法创建一个单选按钮子菜单?
【发布时间】:2017-01-13 03:35:50
【问题描述】:

我制作了一个Sub-Menu。但是,我只能弄清楚如何制作它,以便用户可以检查多项内容。但是,可悲的是,我找不到任何attributes 使其成为to check only one thing at a time 或单选按钮。谁能告诉我这个属性?

【问题讨论】:

  • 请帮忙?会很好...
  • 你是如何制作这些复选框的?你能展示你的代码吗?
  • 您应该始终使用您的代码编辑您的问题。其他人很难理解这种无格式的代码。

标签: android radio submenu


【解决方案1】:

我遇到了同样的问题,我用下面的方法解决了。

<!--Normal View-->
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <!--Radio group that makes only one selected item-->
    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true">

        <!--Different buttons-->
        <RadioButton
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="btn1" />

        <!-- sub buttons -->
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/radios_extra">
            <!-- fill this radio group with extra items and when check btn1 change the visivility for VISIBLE -->
            <RadioGroup
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:inputType="text"
                android:id="@+id/extra_group"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"
                android:visibility="gone" />

        </RelativeLayout>

        <RadioButton
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="bt2" />

    </RadioGroup>

</RelativeLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-10
    • 1970-01-01
    • 2023-03-28
    • 1970-01-01
    相关资源
    最近更新 更多