RadioGroup的使用
2016-05-19 16:40
405 查看
xml文件
<RadioGroup android:id="@+id/sex" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal">
<pre name="code" class="html"><span style="white-space:pre"> </span><!-- 水平horizontal--><span style="font-family: Arial, Helvetica, sans-serif;"> </span>
<span style="white-space:pre"> </span><!-- 水平vertical--><RadioButton android:id="@+id/man" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:text="男" /> <RadioButton android:id="@+id/woman"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="女" /> </RadioGroup>
Java文件
<pre name="code" class="html">private String strSex = "男";
//设置监听事件 RadioGroup sex = (RadioGroup) findViewById (R.id.sex); sex.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup arg0, int id) { strSex = (id == R.id.male ? "男" : "女");
<span style="white-space:pre"> </span>//下一步可以执行你需要的操作 } });
相关文章推荐
- mysql连接字符串,大小写不敏感查询
- 四海众联E350N水滴吸顶AP适配说明
- apache activemq start Address already in use
- iOS面试题整理带答案
- Android Drawable Resources系列5:<level-list>
- .what is difference between NSNotification and protocol? 通知和协议的不同之处?
- ElasticSearch(六)-映射和分析过程
- CentOS-6.3安装配置JDK-7
- 使用linux系统的实用命令总结
- Xshell远程连接Linux时无法使用小键盘的解决方式
- CentOS删除svn版本库
- 关于SpringMVC返回date的格式问题
- 13.5 自定义线程
- 表情符号过滤
- MapReduce执行流程
- <button> 和 input button的对比(实实在在的被坑了一把!)
- java并发编程——并发容器和并发工具介绍
- Algorithm JAVA写算法 验证哥德巴赫猜想
- nginx学习笔记五(nginx的事件模块定义)
- Asp.net中GridView使用详解