为了账号安全,请及时绑定邮箱和手机立即绑定

如何在 Android 中单击 Single Chocie 时出现的多选选项

如何在 Android 中单击 Single Chocie 时出现的多选选项

喵喵时光机 2021-08-25 10:28:09
我想要这样的东西。在所有单项选择下方可能有被动多选按钮。没关系。那可能吗?
查看完整描述

1 回答

?
四季花海

TA贡献1811条经验 获得超5个赞

您可以使用 view.setVisibility(View.Visible 或 View.Gone)控制每个视图的可见性。在单选按钮上设置单击侦听器,并使用该方法显示带有单选按钮的容器布局。


chkIos.setOnClickListener(new OnClickListener() {


@Override

public void onClick(View view) {        

    if (v.isChecked()) {

        multiChoiceView.setVisibility(View.VISIBLE);

    } else {

        multiChoiceView.setVisibility(View.GONE);

    }


});

要在您的图片上构建布局,您可以在每个 RadioButton 下将 RadioGroup 与 LinearLayout 结合起来,以这种方式:


<RadioGroup

    android:layout_width="match_parent"

    android:layout_height="wrap_content">


    <RadioButton

        android:layout_width="wrap_content"

        android:layout_height="wrap_content" />


    <LinearLayout

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_marginStart="20dp"

        android:orientation="vertical">


        <CheckBox

            android:layout_width="match_parent"

            android:layout_height="wrap_content" />


        <CheckBox

            android:layout_width="match_parent"

            android:layout_height="wrap_content" />


        <CheckBox

            android:layout_width="match_parent"

            android:layout_height="wrap_content" />


    </LinearLayout>


    <RadioButton

        android:layout_width="wrap_content"

        android:layout_height="wrap_content" />


</RadioGroup>


查看完整回答
反对 回复 2021-08-25
  • 1 回答
  • 0 关注
  • 155 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信