RadioGroup和Radiobutton


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"

>
<RadioButton
android:id="@+id/r1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="资讯"
android:layout_weight="1"

android:button="@null"
android:gravity="center"
android:textSize="25dp"
/>
<RadioButton
android:id="@+id/r2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="热点"
android:layout_weight="1"
android:button="@null"
android:textSize="25dp"
android:gravity="center"
/>
<RadioButton
android:id="@+id/r3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="博客"
android:layout_weight="1"
android:button="@null"
android:gravity="center"
android:textSize="25dp"

/>
<RadioButton
android:id="@+id/r4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="推荐"
android:button="@null"
android:gravity="center"
android:textSize="25dp"
android:layout_weight="1"
/>

</RadioGroup>

</LinearLayout>

 
   
时间: 2024-08-09 10:39:19

RadioGroup和Radiobutton的相关文章

android中RadioGroup、RadioButton、Spinner、EditText用法详解(含示例截图和源代码)

为了保护版权.尊重原创,转载请注明出处:http://blog.csdn.net/u013149325/article/details/43237757,谢谢! 今天在项目中用到了android中常用的RadioGroup.RadioButton.Spinner.EditText等控件,在此介绍一下它们的用法,希望对需要的朋友有帮助. 一.RadioGroup和RadioButton的使用 RadioButton就是我们常见的单选按钮,一个RadioGroup可以包含多个单选按钮,但是每次只能选

Android控件之RadioGroup与RadioButton(单选控件)

一.RadioGroup与RadioButton 1.什么是RadioGroup: RadioButton的一个集合,提供多选机制 2.什么是RadioButton: RadioButton包裹在RadioGroup中,RadioGroup表示一组RadioButton,下面可以有很多个RadioButton,但只能有一个被选中 3.RadioGroup属性: android:orientation——  设置RadioGroup中RadioButton以什么形式排列(有两个值分别是:horiz

使用RadioGroup与RadioButton实现多选一

RadioGroup是RadioButton的集合, RadioGroup里面可以包含很多RadioButton,提供多选一机制,只能选择其中一个 RadioGroup的orientation(方向)有两个属性android:orientation = {"vertial" ---垂直分布   {"horizontal" ---水平排布 注意RadioGroup一般用于单选,而且选中之后不能取消 而CheckBox一般用于多选,而且选中之后可以取消 例程: 1:主程

RadioGroup结合RadioButton使用切换Fragment片段

界面布局activity_lan_qiu,代码xml设置如下: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height=&quo

Android自学笔记之RadioGroup和RadioButton的使用

1.单独一个RadioButton选择之后无法取消,而CheckBox可以取消,因此不建RadioButton单独使用 RadioGroup与RadioButton: 1 RadioGroup是RadioButton的一个集合,提供多选一机制. 2 属性: android:orientation="" vertical 垂直排布 horizontal 水平排布 决定当前RadioButton以什么方式排布! <RadioGroup <RadioButton android:

Android入门(八):使用RadioGroup 和RadioButton组件建立单选清单

这一章,我们学习RadioGroup 和RadioButton组件,我们新建一个项目,编码过程与前几章的项目类似. 1.建立字符串资源文件strings.xml: <resources> <string name="app_name">健身建议</string> <string name="promptSex">性别:</string> <string name="promptAge&quo

RadioGroup嵌套RadioButton 条目显示错乱解决方法

最近在使用ListView中发现在使用,item含RadioGroup嵌套RadioButton时会出现条目显示错乱的问题. 1. 首先想到的是通过bean类,存放RadioButton的状态.保证每一个条目对应集合里面的一条数据.但是修改之后,在下划之后,在上划.还是会显示错乱   这可咋整? 按理来说一般条目错乱,只要将变化的数据记录到bean中都没问题(如典型的点赞功能). 那这里为什么还会出问题呢?  结合网上的一些资料,最后得出的结论是RadioGroup的状态------其实控件本身

动态布局中RadioGroup的RadioButton有时候不互斥的原因

最近在做一个答题类的模块,有单选.简答.调查问卷等,我是用动态布局的方式生成答题项的,在弄单选的时候遇到一个比较奇葩的问题,在代码中生成RadioGroup和RadioButton的时候,会发现不能互斥,变成多选.通过排查发现,只要每个RadioButton去掉setId的设置就正常了,不过原因还是不明确,继续尝试,发现RadioGroup我也设置了一个Id座位题目标识,调用的是RadioGroup.setId,并且发现,这里设置的ID和后面某个RadioButton设置的Id是一样的...终于

简述RadioGroup和RadioButton的使用

简述RadioGroup和RadioButton的使用 在项目中有身份选择的选项,需要用到RadioGroup和RadioButton,这里做个记录,和大家交流一下. 话不多说,一起看代码 XML代码 <RadioGroup android:id="@+id/login_radiogroup" android:layout_width="wrap_content" android:layout_height="wrap_content" a

Android RadioGroup和RadioButton详解

实现RadioButton由两部分组成,也就是RadioButton和RadioGroup配合使用.RadioGroup是单选组合框,可以容纳多个RadioButton的容器.在没有RadioGroup的情况下,RadioButton可以全部都选中:当多个RadioButton被RadioGroup包含的情况下,RadioButton只可以选择一个.并用setOnCheckedChangeListener来对单选按钮进行监听 1 RadioGroup相关属性: 2 RadioGroup.getC