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

我想要这样的东西。在所有单项选择下方可能有被动多选按钮。没关系。那可能吗?

http://img3.mukewang.com/6125aba60001fc9c07111282.jpg


喵喵时光机
浏览 156回答 1
1回答

四季花海

您可以使用 view.setVisibility(View.Visible 或 View.Gone)控制每个视图的可见性。在单选按钮上设置单击侦听器,并使用该方法显示带有单选按钮的容器布局。chkIos.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View view) {&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; if (v.isChecked()) {&nbsp; &nbsp; &nbsp; &nbsp; multiChoiceView.setVisibility(View.VISIBLE);&nbsp; &nbsp; } else {&nbsp; &nbsp; &nbsp; &nbsp; multiChoiceView.setVisibility(View.GONE);&nbsp; &nbsp; }});要在您的图片上构建布局,您可以在每个 RadioButton 下将 RadioGroup 与 LinearLayout 结合起来,以这种方式:<RadioGroup&nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; android:layout_height="wrap_content">&nbsp; &nbsp; <RadioButton&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content" />&nbsp; &nbsp; <LinearLayout&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_marginStart="20dp"&nbsp; &nbsp; &nbsp; &nbsp; android:orientation="vertical">&nbsp; &nbsp; &nbsp; &nbsp; <CheckBox&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content" />&nbsp; &nbsp; &nbsp; &nbsp; <CheckBox&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content" />&nbsp; &nbsp; &nbsp; &nbsp; <CheckBox&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="match_parent"&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content" />&nbsp; &nbsp; </LinearLayout>&nbsp; &nbsp; <RadioButton&nbsp; &nbsp; &nbsp; &nbsp; android:layout_width="wrap_content"&nbsp; &nbsp; &nbsp; &nbsp; android:layout_height="wrap_content" /></RadioGroup>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java