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 介绍背水一 ...
随机推荐
- fdisk命令使用说明
CentOS我新建了几个分区,比如/dev/sda4,sda5我想挂在一个目录下,用mount /dev/sda5 /disk ,总提示mount:you must specify the fil ...
- java中图片文件的判断
javax.imageio 类 ImageIO BufferedImage bi = ImageIO.read(resFile);//resFile --- InputStream if(bi == ...
- Unity 3D 中实现对物体 位置(position) 旋转(rotation) 大小(scale) 的全面控制
今天分享一些基础控制的脚本 1.位置(Position): 控制位置很简单,首先要知道要在xyz哪几个轴上移动,确定好后定义代表着那些轴的移动变量,速度(m_speed在函数外定义为全局变量)然后通过 ...
- 简单的session共享的封装
目的 session存储在缓存服务器上(各种缓存服务器上均可,本文以memcached为例),但对开发者来说,他不用关注,只需要调用request.getSession()方法即可获取到session ...
- webapp,liveapp: 流式布局和rem布局
liveapp场景应用,一般针对的是移动端,近来也是很火,颇有一些感受,拿来分享一下. 页面宽度范围: 一般移动端页面我们的像素范围是320px-640px,最大640px,最小320px,所以设计稿 ...
- Android 学习笔记之Volley(八)实现网络图片的数据加载
PS:最后一篇关于Volley框架的博客... 学习内容: 1.使用ImageRequest.java实现网络图片加载 2.使用ImageLoader.java实现网络图片加载 3.使用NetWork ...
- WebService基于SoapHeader实现安全认证
本文仅提供通过设置SoapHeader来控制非法用户对WebService的调用,如果是WebService建议使用WSE3.0来保护Web服务,如果使用的是Viaual Studio 2008可以使 ...
- Python内置函数解析
我们知道,为了方便使用,python内置了一系列常用及关键的函数,如type().下面将对这些函数进行逐一分析.解释. Python内置函数表: 1. abs():返回绝对值.如abs(-1)= 1. ...
- 轻松认识JVM运行时数据区域(使用思维导图)
下面是个人阅读周志明编写的深入浅出Java虚拟机做成思维导图的笔记,线条.颜色和图片的视觉印象比起单纯文字笔记好得太多了,文字笔记的枯燥以及硬性记忆我就不再多说,特别对于JVM这块略微有点枯燥的知识, ...
- JS 将一段文本 每个英文首字母大写
function replaceStr(str){ // 正则法 str = str.toLowerCase(); var reg = /\b(\w)|\s(\w)/g; // \b判断边界\s判断空 ...