效果图如下:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="fill_parent"
  4. android:layout_height="fill_parent"
  5. android:orientation="vertical" >
  6. <TextView
  7. android:id="@+id/radiobutton_textview"
  8. android:layout_width="fill_parent"
  9. android:layout_height="50dip"
  10. android:background="@android:drawable/title_bar"
  11. android:gravity="center_vertical"
  12. android:textAppearance="?android:attr/textAppearanceLarge"
  13. android:textSize="18dip"
  14. android:textStyle="bold" />
  15. <RadioGroup
  16. android:id="@+id/group"
  17. android:layout_width="fill_parent"
  18. android:layout_height="wrap_content"
  19. android:orientation="vertical" >
  20. <RadioButton
  21. android:id="@+id/button1"
  22. android:layout_width="fill_parent"
  23. android:layout_height="50dip"
  24. android:button="@null"
  25. android:drawableRight="@android:drawable/btn_radio"
  26. android:paddingLeft="30dip"
  27. android:text="Android新手"
  28. android:textSize="20dip" />
  29. <View
  30. android:layout_width="fill_parent"
  31. android:layout_height="1px"
  32. android:background="?android:attr/listDivider" />
  33. <RadioButton
  34. android:id="@+id/button2"
  35. android:layout_width="fill_parent"
  36. android:layout_height="50dip"
  37. android:button="@null"
  38. android:drawableRight="@android:drawable/btn_radio"
  39. android:paddingLeft="30dip"
  40. android:text="Android高手"
  41. android:textSize="20dip" />
  42. </RadioGroup>
  43. </LinearLayout>
  1. package sdfasdf.sadf;
  2. import android.app.Activity;
  3. import android.os.Bundle;
  4. import android.widget.RadioGroup;
  5. import android.widget.RadioGroup.OnCheckedChangeListener;
  6. import android.widget.TextView;
  7. public class SdfsadfasdfasdffActivity extends Activity {
  8. private TextView textView;
  9. private RadioGroup group;
  10. @Override
  11. public void onCreate(Bundle savedInstanceState) {
  12. super.onCreate(savedInstanceState);
  13. setContentView(R.layout.main);
  14. textView = (TextView) findViewById(R.id.radiobutton_textview);
  15. group = (RadioGroup) findViewById(R.id.group);
  16. // 单选按钮组监听事件
  17. group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
  18. @Override
  19. public void onCheckedChanged(RadioGroup group, int checkedId) {
  20. // 根据ID判断选择的按钮
  21. if (checkedId == R.id.button1) {
  22. textView.setText("Android新手");
  23. } else {
  24. textView.setText("Android高手");
  25. }
  26. }
  27. });
  28. }
  29. }

http://blog.csdn.net/furongkang/article/details/7272512

最新文章

  1. 转载 - Vultr VPS注册开通且一键快速安装PPTP VPN和电脑连接使用
  2. 入门:HTML:hello world!
  3. 递推DP URAL 1119 Metro
  4. LINQ之路 1: LINQ介绍
  5. MATLAB 函数
  6. 【JavaScript】JavaScript脚本代码的位置及在页面中的执行顺序
  7. [iOS基础控件 - 6.10.2] PickerView 自定义row内容 国家选择Demo
  8. Spring、基本类型属性和集合类型属性的注入
  9. JSP动态网站环境搭建应用中的详细步骤(Tomcat和Apache/IIS的整合)
  10. elasticsearch映射
  11. PHP字符串替换str_replace()函数4种用法详解
  12. 不输入密码执行SUDO命令
  13. 「面向打野编程」iOS多线程:CGD
  14. Visual Studio进行Web性能测试- Part III
  15. IdentityServer4关于多客户端和API的最佳实践【含多类型客户端和API资源,以及客户端分组实践】【下】
  16. odoo订餐系统之订单相关知识点理解
  17. hadoop - 基础操作
  18. JS书写规范
  19. Collections 集合工具类
  20. NOIp2018提高组游记

热门文章

  1. LDAP-openldap服务部署和测试(YUM安装)
  2. Linux下DNS简单部署(主从域名服务器)
  3. E. Binary Numbers AND Sum
  4. 《Linux内核分析与实现》 第五周 读书笔记
  5. 《Linux内核分析》第八周:进程的切换和系统的一般执行过程
  6. github 学习心得
  7. 第三个Sprint冲刺第6天
  8. 无限级结构SQL查询所有的下级和所有的下级
  9. java中实现全局变量的功能
  10. MySQL_基础知识