RadioGroup和CheckBox的使用

界面控件之选项组件(RadioGroup和CheckBox)--代码 界面控件之选项组件(RadioGroup和CheckBox)--代码,Android开发学习26,博客主页: http://blog.youkuaiyun.com/ypist. 立即下载

1.布局文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
   <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />
    
   <RadioGroup android:id="@+id/genderGroup"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content">
          <RadioButton 
               android:id="@+id/male"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="@string/male"/>
          <RadioButton 
               android:id="@+id/female"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="@string/female"/>
       
   </RadioGroup>
   
   <CheckBox android:id="@+id/swim"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:text="@string/swim"/>
   <CheckBox android:id="@+id/basket"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:text="@string/basket"/>
   <CheckBox android:id="@+id/foot"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:text="@string/foot"/>
</LinearLayout>

2.RadioAndCheckBox.java

package wei.cao.Android;

import android.app.Activity;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

public class RadioAndCheckBox extends Activity {
	
	private RadioGroup genderGroup=null; 
	private RadioButton femaleButton=null;
	private RadioButton maleButton=null;
	private CheckBox swimBox=null;
	private CheckBox basketBox=null;
	private CheckBox footBox=null;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        genderGroup=(RadioGroup)this.findViewById(R.id.genderGroup);
        femaleButton=(RadioButton)this.findViewById(R.id.female);
        maleButton=(RadioButton)this.findViewById(R.id.male);
        
        swimBox=(CheckBox)this.findViewById(R.id.swim);
        basketBox=(CheckBox)this.findViewById(R.id.basket);
        footBox=(CheckBox)this.findViewById(R.id.foot);
        
        genderGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){

			public void onCheckedChanged(RadioGroup group, int checkedId) {
				// TODO Auto-generated method stub
				if(femaleButton.getId()==checkedId)
				{
					Toast.makeText(RadioAndCheckBox.this, "female",Toast.LENGTH_SHORT).show();
				}
				else if(maleButton.getId()==checkedId)
				{
					Toast.makeText(RadioAndCheckBox.this, "male",Toast.LENGTH_SHORT).show();
					
				}
			}
        	
        	
        });
        
        swimBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){

			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// TODO Auto-generated method stub
				if(isChecked)
				{
					System.out.println("swim is checked");
				}
				
			}
        	
        	
        });
        basketBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){

   			public void onCheckedChanged(CompoundButton buttonView,
   					boolean isChecked) {
   				if(isChecked)
   				{
   					System.out.println("basketBox is checked");
   				}
   				
   			}
           });
        footBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){

   			public void onCheckedChanged(CompoundButton buttonView,
   					boolean isChecked) {
   				if(isChecked)
   				{
   					System.out.println("footBox is checked");
   				}
   				
   			}
           });
        
    }
}



 

AutoCAD 2025在Win10/Win11上的官方安装、配置与问题排查全指南 对于需要在 Windows 11 或 Windows 10 系统上部署 AutoCAD 2025 的设计师、工程师和 IT 支持人员来说,一个稳定、合规的安装流程是高效工作的基石。网络上充斥着各种所谓的“免费下载”和“一键安装”教程,但这些资源往往来源不明,可能捆绑恶意软件、导致软件崩溃,甚至引发严重的许可合规风险。本文旨在提供一个清晰、安全、基于官方最佳实践的 AutoCAD 2025 安装与配置指南,重点解决在 Windows 11 和 Windows 10 系统上部署时可能遇到的兼容性问题、安装失败以 阅读详情

相关推荐

SIMPLIS实战:从零构建理想BUCK电路,精准计算与POP稳态分析

本文详细介绍了如何使用SIMPLIS软件从零开始构建并仿真一个理想的BUCK降压电路。通过设定关键参数、计算理想器件值,并搭建仿真模型,文章重点演示了暂态仿真以观察电路上电过程,并深入讲解了高效的POP(周期性工作点)稳态分析技术,帮助工程师快速验证设计、评估稳态性能,从而加速电源设计迭代。

weixin_29165465的博客 398

微信小程序组件 checkbox-group 和 radio-group checkbox和radio 的关系

【代码】微信小程序组件 checkbox-group 和 radio-group checkbox和radio 的关系。

m0_63281943的博客 594

MacBook 本地化部署 Dify 指南

dify 怎么安装部署 有哪些坑 !

weixin_44542598的博客 1529

微信小程序学习之路——表单组件(一)

radio组件 1.radio-group 在小程序中<radio/>不能单独使用,同一组<radio/>需要包含在一个<radio group/>中,这样才能形成一组单项选择按钮,<radio/>的选中态不能直接获取,需要通过<radio-group>的change事件进行获取。<radio-group>内部可以包含其他...

创作星球 1914

论文浅读之PIP-Net: Patch-Based Intuitive Prototypes for Interpretable Image Classification

这篇文章的主要贡献包括:1 提出了一种新型的可解释图像分类模型PIP-Net,它基于原型部分学习可解释的原型,实现内置解释性。2 PIP-Net采用自监督学习的新正则化方法,学习原型之间的相似性,使得 latent 空间中的相似性能更好地与人类视觉感知相一致,从而减小了所谓的语义差距。3 PIP-Net可解释为一个稀疏的打分表,它可以检测图像是否属于任何类,或是否属于多个类。它也可以对OOD数据进行分类并说“我没有看到过这个”。

qq_49370210的博客 1792

1.3、云计算HCIP融合存储产品及部署

目标:描述Oceanstor V3系列存储产品系统组成及产品定位 描述Oceanstor V3硬件结构及软件架构 掌握存储系统与主机系统之间的连接 一、存储型号 低端型存储:Oceanstor 2200 2600 2800 V3/V5 终端型存储:Oceanstor 5300 5500 5600 5800 6800 V3/V5 高端型存储:Oceanstor 18000 二、Oceanstor V3系列存储系统定位 OceanStor V3系列存储系统是华为根据存储产品应用现状和存储

weixin_43666279的博客 1656

RadioGroup作为viewpage的子布局,RadioGroup单选失效

选择一个GroupButton后,再选择另一个,结果两个都选中了,继续选择,四个全部被选中。明明四个GroupButton都是包裹在RadioGroup中的,按理说,选择第二个时,之前被选中的应该变为未被选中。删除原来包裹的LineaLayout布局,再运行即可实现单选,效果如下,原本是想用RadioButton的text显示选项,另外用TextView显示选型内容。于是为了排版使用了,线性布局,发现了这个问题。至于为什么被线性布局包裹后,RadioButton就不能单选了,在下还甚是不解,望诸君解惑!

2301_79077979的博客 464

【OpenClaw从入门到精通】第03篇:吃透Gateway/Skills/ClawHub核心概念(2026实测+避坑)

本文针对OpenClaw新手易混淆的核心概念痛点,以通俗类比+实操演示拆解OpenClaw核心、Gateway、Skills、ClawHub四大组件。通过“数字员工团队”类比明确各组件定位:OpenClaw核心是“老板”(调度中心)、Gateway是“前台+后勤”(后台进程)、Skills是“专业员工”(功能插件)、ClawHub是“人才市场”(技能商店)。补充版本更名史、技能加载优先级、ClawHub与GitHub区别等关键细节,结合“AI融资新闻查询并邮件推送”虚拟案例演示组件协同流程,梳理5个高频认知

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 5058

RadioGroup和CheckBox

RadioButton和CheckBox

火星男孩的分享空间 2794

电子电器架构 --- OEM企标中规定ECU启动时间的目的

电子电器架构 --- OEM企标中规定ECU启动时间的目的

Soly_kun的博客 225

Open3D 点云变换【2025最新版】

点云平移、旋转、缩放、欧式变换的python代码实现。博客长期更新,本文最近更新时间为:2025年1月16日。

点云侠的博客 37万+

基本组件之RadioGroup与CheckBox

1.单选按钮使用RadioButton组件,通常与RadioGroup一起使用 RadioButton是Button的子类,所以RadioButton可以使用Button的支持的各种属性 RadioButton组件中的android:checked 属性用于指定选中状态,属性值为true,表示选中;属性值为false时,表示取消选中,默认为false。 ...

qq1450901761的博客 509

harbor x509: certificate signed by unknown authority【20251222】

本教程通过「合并证书链(服务器端)+ 预置根 CA(客户端)」彻底解决了自签名证书的 x509 错误,同时集成了 Trivy 漏洞扫描,实现了 Harbor 从搭建到实用的全流程。证书链合并是服务器端的关键,确保客户端获取完整信任路径;客户端需同时配置「系统信任库 + Docker 信任目录」,避免 Docker 独立信任机制导致的问题;所有 IP 需保持一致(Harbor 配置、证书绑定、客户端访问),是避免错误的基础。

老韩的Linux云计算架构师进阶之路 682

常用的组件RadioGroup和CheckBox笔记

RadioGroup和CheckBox在Android应用中相对常见,下面就把本人初次学习的笔记放上来。 Activity Layout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layou

Stop Tears 1139

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

控件RadioGroup、RadioButton和CheckBox的使用

1、RadioGroup和RadioButton的使用,即单选框    首先在xml文件中定义,每一组选项先用标签标记    然后在其中标记 2、每一组只能选中一个按钮 3、定以好后,在activity中,首先要分别定义RadioGroup和RadioButton变量,有个按钮就要定义几个,     然后分别使用findViewById(),来找到对象     最后要为RadioGro

929

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

学习CheckBox、RadioButton和RadioGroup控件

CheckBox和RadioButton较为简单,主要是对单击事件的响应,暂时不做描述。 RadioGroup控件 在添加时,会自带三个RadioButton按钮。 也可以向下面代码中那样增加单选按钮,未列出事件处理函数。 public class MainActivity : Activity { int count = 1; RadioButton rb; CheckBox cb; RadioGroup rg;

tsliuch的专栏 297

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

RadioGroup和CheckBox使用示例

1 main.xml文件如下 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearLayout" android:layout_width="fill_parent" android:layout_height="fill_

谷哥的小弟 1612

Android——RadioGroup和CheckBox

xml &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout...

weixin_34195364的博客 186

常用的Android Widget组件学习③-checkbox和radiogroup的介绍和应用。

二、单项选择(radiogroup)介绍和应用:在main.xml中添加一个button这个button的响应时间: Button radio_group_button=(Button) findViewById(R.id.radio_group_button); radio_group_button.setOnClickListener(radio_group_button_listener); private Button.OnClickListener radio_

Hello_MissのHome 2145

android的屏幕朗读checkbox,Android学习笔记:常用控件 RadioGroup和CheckBox

RadioGroup和CheckBox是android的常用控件,本文自做简单介绍和学习笔记,所以所用的控件样式选用android默认的样式。先看下代码实现的效果图图中,上面两个(male和female)为一个RadioGroup中的两个RadioButton,下面三个为CheckBox。一个RadioGroup里面的内容只可单选,CheckBox可多选。接下来是代码部分布局文件代码activit...

weixin_36211244的博客 291

android toast 和checkbox and radiogroup的使用

1. main.xml 布局文件     &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:l...

今天最成功 248

Widgets之RadioButton、RadioGroup和CheckBox

1.RadioButton选中不可以取消选择。 2.RadioGroup中包含多个RadioButton,并且使用的onCheckedChangeListener是RadioGroup的onCheckedChangeListener,而不是RadioButtonCompoundButton.OnCheckedChangeListener。这里一定要注意不然会有问题。 rbtn1.setOnCh

zhaoxiaoyao1987的专栏 504

radiogroup多选_3.Android之单选按钮RadioGroup和复选框Checkbox学习

单选按钮和复选框在实际中经常看到,今天就简单梳理下。首先,我们在工具中拖进单选按钮RadioGroup和复选框Checkbox,如图:xml对应的源码:android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" >android:id="@+id/r...

weixin_36146811的博客 416

matlab radiogroup,RadioGroup和CheckBox的使用 | 学步园

1.布局文件:android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" >android:layout_width="fill_parent"android:layout_height="wrap_content"android:text="@stri...

weixin_33274728的博客 156
上一篇: Activity的生命周期
下一篇: Service(二)
whilelie
博客等级 码龄16年 24粉丝 87原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值