Android的实战基础——入门视图单复选按钮

相较上一章这章就很少了,进行我们的但复选按钮的了解。

一`单选:RadioButton:

单选按钮:如果想要有互斥效果必须配合RadioGroup使用

       是TextView的子类

属性:android:checked="" 设置默认选择true 表示选中false 表示不选中

在代码中可通过实例化对象radioButton调用setChecked方法达到同  样的效果

RadioGroup:

    单选按钮组:如果RadioButton想要有互斥效果则必须配合RadioGrou     p使用是LinearLayout的子类,横向或者纵向排列

单选按钮组的监听器:OnCheckedChangedListener()

二`多选:CheckBox

 可以中,再次点击则取消中状

如何取当前的checkBox 是否被

checkBox.isChecked(); 的返回值来判断 当返回值是true的时候 则被选中否则 没有被选中

<RadioGroup
    android:id="@+id/rg"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <RadioButton
        android:id="@+id/rb"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />
    <RadioButton
        android:id="@+id/rb2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />
</RadioGroup>
<CheckBox
    android:id="@+id/cb1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />
<CheckBox
    android:id="@+id/cb2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />
<CheckBox
    android:id="@+id/cb3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />
简单的实现,由于内容过于简单效果图就不给予展示了。
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值