andriod RadioButton
<?xml version="1.0" encoding="UTF-8"?> <LinearLayout android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="多选控件:" android:id="@+id/label"/>
<RadioGroup android:orientation="horizontal" android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/radionGroup">
<RadioButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="女" android:id="@+id/radioFemale"/>
<RadioButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="男" android:id="@+id/radioMale" android:checked="true"/>
<Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="确定" android:id="@+id/ok"/>
</RadioGroup> </LinearLayout>
package com.example.yanlei.mytk; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton; public class MainActivity extends AppCompatActivity { private RadioButton radioFemale;
private RadioButton radioMale;
private Button ok; @Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); radioFemale=(RadioButton)findViewById(R.id.radioFemale);
radioMale=(RadioButton)findViewById(R.id.radioMale);
ok=(Button)findViewById(R.id.ok); ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String result = "你选择的是:";
if (radioFemale.isChecked()) {
setTitle(result + "女");
} else {
setTitle(result + "男");
}
}
});
}
}
andriod RadioButton的更多相关文章
- Andriod 自定义控件之创建可以复用的组合控件
前面已学习了一种自定义控件的实现,是Andriod 自定义控件之音频条,还没学习的同学可以学习下,学习了的同学也要去温习下,一定要自己完全的掌握了,再继续学习,贪多嚼不烂可不是好的学习方法,我们争取学 ...
- RadioButton与CheckBox
笔者长期从事于数据库的开发,算了,不提当年了,因为一直用的是小语种(PowerBuilder),还是来说说这两个最常见的控件吧! RadioButton(单选)和CheckBox(多选) 先来看看继承 ...
- 【WPF】值是枚举的RadioButton 绑定问题
源 1.RadioButton 2.IValueConverter 3.枚举 xaml实现 <RadioButton Content="单打热身" GroupName=&qu ...
- Android RadioGroup和RadioButton详解
实现RadioButton由两部分组成,也就是RadioButton和RadioGroup配合使用.RadioGroup是单选组合框,可以容纳多个RadioButton的容器.在没有RadioGrou ...
- react native RadioButton(单选按钮)
刚刚写完这个多选按钮,我觉得没有单选的话,总会觉得有一点点不爽,因为在项目中我也没有用到单选,所以我没有好好研究源码,所以我在Github上找了一下,发现有一个挺好的,简单,不花哨. 在Github上 ...
- RadioButton(单选按钮)文字在按钮的左边
<RadioButton style="@style/CustomCheckboxTheme" android:layout_width="fill_parent& ...
- Web Api 与 Andriod 接口对接开发经验
最近一直急着在负责弄Asp.Net Web Api 与 Andriod 接口开发的对接工作! 刚听说要用Asp.Net Web Api去跟 Andriod 那端做接口对接工作,自己也是第一次接触Web ...
- RadioGroup、RadioButton、CheckBox、Toast用法
xml布局文件如下: <RadioGroup android:id="@+id/sex" android:layout_width="wrap_content&qu ...
- 背水一战 Windows 10 (33) - 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch
[源码下载] 背水一战 Windows 10 (33) - 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch 作者:webabcd 介绍背水一 ...
随机推荐
- [原]零基础学习视频解码之seek
现在,我们要添加一些功能,当你看不能倒带的电影,是不是很烦? 那么函数av_seek_frame功能看起来是多么赏心悦目. 我们将让左,右箭头来回走在影片中通过一个小的向上和向下箭头很多,其中“三多一 ...
- mingW与cygwin
转自:http://hi.baidu.com/ooxxer/item/d25dccc072846a50ac00ef7e# 首先MingW和cygwin都可以用来跨平台开发. MinGW是Minima ...
- CSS实例
CSS 实例 CSS背景 设置页面的背景颜色 设置不同元素的背景颜色 设置一个图像作为页面的背景 错误的的背景图片 如何在水平方向重复背景图像 如何定位背景图像 一个固定的背景图片(这个图片不会随页面 ...
- CentOS 6.4 快速安装Nginx笔记
CentOS 6.4 快速安装Nginx笔记 本系列文章由ex_net(张建波)编写,转载请注明出处. http://blog.csdn.net/ex_net/article/details/9860 ...
- java中String byte HexString的转换
原文:http://blog.sina.com.cn/s/blog_62e9ec530101ebv6.html HexString——>byte public static byte[] hex ...
- http协议客户端向服务器端请求时一般需要发送的内容
out.println("GET /shopping/index.html HTTP/1.1");//请求行 包括请求方式,文件路径, http协议版本(必写)请求头.... ou ...
- java中解决组件重叠的问题(例如鼠标移动组件时)
java中解决组件覆盖的问题! 有时候在移动组件的时候会出现两个组件覆盖的情况,但是你想让被覆盖的组件显示出来或者不被覆盖! 在设计GUI时已经可以定义组件的叠放次序了(按摆放组件的先后顺序) ...
- html5 自定义数据属性 ,也就是 data-* 自定义属性---笔记。
html5 自定义数据属性 ,也就是 data-* 自定义属性. 例如 <div data-last-value="43" data-hidden="true& ...
- 【转载】Unix Shell中用[-n]判断字符串不为NULL
转载自:http://blog.sina.com.cn/s/blog_541086430100mosm.html 在Unix Shell中,可以使用-n来判断一个string不是NULL值,但是之前却 ...
- 100款免费的圣诞节矢量图标素材(PSD & SVG)
圣诞节的脚步越来越近了.今天,我们给大家收集了100个美丽的圣诞矢量图标素材.这套圣诞矢量图标集包含 PSD 和 SVG 两种格式,基于 Creative Commons 协议,可以在商业和个人项目中 ...