这是关于RadioButton一个坑爹的问题,请让我自杀好吗!
来源:互联网 发布:mac safari 编辑:程序博客网 时间:2024/05/17 01:18
1.需求是这样的:
选一个宝宝,实现思想是RadioButton单选,
<RadioGroup android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:orientation="horizontal"> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="20dp" android:button="@null" android:checked="true" android:drawableLeft="@drawable/radio_button_sexchoice" android:drawablePadding="5dp" android:gravity="center_vertical" android:text="男宝宝" android:textColor="@drawable/radio_button_sexchoice_textcolor" /> <RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@null" android:drawableLeft="@drawable/radio_button_sexchoice_woman" android:drawablePadding="5dp" android:text="女宝宝" android:textColor="@drawable/radio_button_sexchoice_textcolor" /></RadioGroup>好,默认第一个,开心的变异运行,恩,不错,可以,选下女宝宝,恩???什么鬼?都选中了?不信自己试试!
说好的单选呢?亲?去哪了?看起来一点错误都没有。
难道是drawable写错了?
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/zc_man_hover" android:state_checked="true" /> <item android:drawable="@drawable/zc_man" android:state_checked="false" />
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="@color/orange" android:state_checked="true" /> <item android:color="@color/gray" android:state_checked="false" />
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/zc_woman_hover" android:state_checked="true" /> <item android:drawable="@drawable/zc_woman" android:state_checked="false" />
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="@color/orange" android:state_checked="true" /> <item android:color="@color/gray" android:state_checked="false" />包大人,我冤枉啊! 我没有写错啊!(你全家都写错!我才没写错)
那么,怎么办?
重启。还不行?换台电脑吧这台电脑坏了。法克
找了下属性,再看看写的
<RadioGroup android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:orientation="horizontal"> <RadioButton android:id="@+id/choice_boy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="20dp" android:button="@null" android:checked="true" android:drawableLeft="@drawable/radio_button_sexchoice" android:drawablePadding="5dp" android:gravity="center_vertical" android:text="男宝宝" android:textColor="@drawable/radio_button_sexchoice_textcolor" /> <RadioButton android:id="@+id/choice_girl" android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@null" android:drawableLeft="@drawable/radio_button_sexchoice_woman" android:drawablePadding="5dp" android:text="女宝宝" android:textColor="@drawable/radio_button_sexchoice_textcolor" /></RadioGroup>妈蛋,没有变化啊,还是一样的啊,再看!多了什么?id!哦买噶,不申明id,会导致Radiobutton不互斥!
再见,这个世界!
0 0
- 这是关于RadioButton一个坑爹的问题,请让我自杀好吗!
- 请帮我解决一个关于AUTOCAD的问题,谢谢!
- 请各位高手看一下.这是一个关于定义冲突的问题.我应该怎么解决.急,忘各位高手指点!
- 这是一个关于我的故事
- 一个农民工的请求;城里人,不要让我让座好吗?
- 请允许我悄悄的爱你,好吗?
- 大家好,请VB的高手帮我解决一个关于导入EXCEL数据库的问题
- 让我抱一下好吗
- 让我很纠结的一个问题
- 一个让我很困扰的问题
- 亲爱的,我的眼泪不多,请不要我再为你流泪好吗?
- 亲爱的,我的眼泪不多,请不要我再为你流泪好吗?
- 亲爱的,我的眼泪不多,请不要我再为你流泪好吗?
- 亲爱的,我的眼泪不多,请不要我再为你流泪好吗?
- 以后请每天做一个codewars好吗。
- 关于用sufer做影像图的问题,是一个色彩矩阵,请懂的高手帮忙看一下。
- 一个让我感触很深的求职故事,“请给我一次机会,让我成就你”
- 请大神帮我解释一下一个oc的问题
- UltraEdit语法高亮配制方法
- 搭建SSH框架时遇到的问题及解决方法
- python 文件拷贝copy操作 shutill
- 解决: Gradle DSL method not found: 'apt()'
- C语言函数sscanf()的用法
- 这是关于RadioButton一个坑爹的问题,请让我自杀好吗!
- 机器学习面试问题3
- 为什么你在虚度年华
- is和as操作符
- STM8L15x系列单片机独立看门狗配置
- 数据结构实验之栈一:进制转换
- UITableView-编辑模式(多选移动删除)
- 韩购物网站服务器遭黑客攻击 千万用户信息被泄
- 生产者消费者模型——blocking queue和CountDownLaunch