RadioButton
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"tools:context=".MainActivity"><TextViewandroid:id="@+id/textView"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="性别" /><RadioGroupandroid:id="@+id/ra"android:layout_width="match_parent"android:layout_height="wrap_content"><RadioButtonandroid:id="@+id/radioButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="男" /><RadioButtonandroid:id="@+id/radioButton2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="女" /></RadioGroup><TextViewandroid:id="@+id/textView2"android:layout_width="match_parent"android:layout_height="wrap_content" /></LinearLayout>
package com.example.radiobutton;import androidx.appcompat.app.AppCompatActivity;import android.os.Bundle;
import android.widget.RadioGroup;
import android.widget.TextView;public class MainActivity extends AppCompatActivity {private TextView tips;private RadioGroup sex;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);tips=(TextView)findViewById(R.id.textView2);sex=(RadioGroup)findViewById((R.id.ra));sex.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {@Overridepublic void onCheckedChanged(RadioGroup group, int checkedId) {if(checkedId==R.id.radioButton){tips.setText("您已选择了男");}else{tips.setText("您已选择了女");}}});}
}
RadioButton相关推荐
- Android RadioButton 修改选择框
效果图 是否被选中打印效果图 RadioButon 是单选框 ,选中之后再次点击无法取消,这样呢我们可以配合RadioGroup 使用,选择其他的RadioButton 这样的话刚才的的那个就取消了 ...
- android radiobutton 分组,Android 第十课——UI RadioButton
常用基础空组件 5 RadioGroup RadioButton 单选按钮时常用组件之一,但是开发过程中虽然很多地方会用到单选按钮,但是却不会用Android系统提供的原始样式,类似我们在写html时 ...
- 【Visual Studio 扩展工具】如何在ComponentOneFlexGrid树中显示RadioButton
概述 在ComponentOne Enterprise .NET控件集中,FlexGrid表格控件是用户使用频率最高的控件之一.它是一个功能强大的数据管理工具,轻盈且灵动,以分层的形式展示数据(数据呈 ...
- android 自定义radiobutton 样式,RadioButton自定义点击时的背景颜色
一.应用场景: 在使用 RadioButton 时,有时我们会需要自定义点击时改变背景颜色的效果. 效果图: RadioButton自定义背景颜色.jpg 二.实现步骤: 1.新建一组 RadioBu ...
- Android UI系列-----CheckBox和RadioButton(1)
主要记录一下CheckBox多选框和RadioGroup.RadioButton单选框的设置以及注册监听器 1.CheckBox 布局文件: <LinearLayout xmlns:androi ...
- 【Python】Radiobutton组件 LabelFrame组件 Entry组件
Radiobutton组件 Radiobutton组件跟Checkbutton组件的用法基本一致,唯一不同的是Radiobutton实现的是"单选"的效果. 要实现这种互斥的效果, ...
- RadioGroup,RadioButton 和CheckBox
为什么80%的码农都做不了架构师?>>> RadioButton和CheckBox的区别: 1.单个RadioButton在选中后,通过点击无法变为未选中 单个CheckBox ...
- WPF中RadioButton绑定数据的正确方法
RadioButton一般用于单选的时候,也就是从一组值中选择一个值. 比如性别有"男"和"女"两种取值,而对于一个员工的实例来说,性别的取值要么是男,要么是女 ...
- Android 定制RadioButton样式
三种方法 1.使用XML文件进行定义 res/drawable/radio.xml <?xml version="1.0" encoding="utf-8" ...
- Material Designer的低版本兼容实现(十)—— CheckBox RadioButton
ChekBox的用途我们就不必多说了,算是一个很古老的控件了,何其类似的还有RadioButton,这个东西因为我目前还没写出来,所以用了别人的一个lib,这下面会说到.顺便说一句,如果你的app是在 ...
最新文章
- 基于mysqld_multi实现MySQL 5.7.24多实例多进程配置
- 【Android 安装包优化】使用 lib7zr.so 动态库处理压缩文件 ( 拷贝 lib7zr.so 动态库头文件到 Android 工程中 | 配置 CMakeLists.txt 构建脚本 )
- POJ 2965.The Pilots Brothers‘ refrigerator
- pixhawk position_estimator_inav.cpp思路整理及数据流
- Linux select/poll机制原理分析
- android各组件翻译,Android App框架指南(译文)
- Excel 使用VBA 使表格的值被修改后填充颜色标注
- windows安装使用jaeger链路追踪
- vue3.0引入ant-design-vue报错 export ‘default‘ (imported as ‘Vue‘) was not found in ‘vue‘
- 231 · 自动补全
- 数据全生命周期管理应用平台的组成
- 波特率和比特率的区分
- hadoop实现单词统计
- 游戏制作之路(48)地形纹理工具
- 163邮箱格式 ,个人邮箱的正确格式
- excel拆分工具怎么拆分表格?
- 键盘右上角三个灯的作用
- 最新 955 不加班的公司名单
- 求解TSP问题神器——elkai(简单好用)
- DDD - 六边形架构和CQRS架构
热门文章
- 配置faster-rcnn pytorch1.0.0版本实现faster R-CNN
- 【统计学01】概括性描述-集中趋势,离散程度,分布形状度量
- 国产车规工业芯片,开发板,工业控制PLC,DCS,电力控制
- SQLServer_where添加类似ifelse条件(casewhen)
- html向下滑动动画,CSS动画:(向下滑)slidedown效果_html/css_WEB-ITnose
- 水星mw300r服务器无响应,水星MW300R无线路由器无线网频繁掉线的解决方法除了重启路由还有???...
- 飞流秀色交易网秦再收到现金款项4亿元人民币 赎回中植8800万美金可转债
- 结构体占用内存的计算
- Linux服务器综合练习
- Java 泛型获取实体类型