设为首页 加入收藏

TOP

[APP] Android 开发笔记 004-Android常用基本控件使用说明(六)
2017-10-13 10:47:29 】 浏览:11597
Tags:APP Android 开发 笔记 004-Android 常用 基本 控件 使用说明
;      -setImageBitmap(Bitmap bitmap);    使用bitmap 替换默认图片,bitmap一般通过网络获取

    使用方法:

        img.setImageResource(R.mipmap.ic_launcher);


RadioButton


    ,RadioButton单选按钮,就是几个选项只能选中一个。 因此我们要把RadioButton放到RadioGroup按钮组中,从而实现 单选功能!

    1)代码:

     <RadioGroup
            android:id="@+id/radioGroup"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
     
            <RadioButton
                android:id="@+id/btnMan"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="男"
                android:checked="true"/>
     
            <RadioButton
                android:id="@+id/btnWoman"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="女"/>
        </RadioGroup>

    2)控件的监听方法:

        ReadioGroup监听方法:setOnCheckedChangeListener()

    3)获取选择的值的方法:getText()

            RadioGroup radgroup = (RadioGroup) findViewById(R.id.radioGroup);
            //第一种获得单选按钮值的方法  
            //为radioGroup设置一个监听器:setOnCheckedChanged()  
            radgroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
                @Override
             

首页 上一页 3 4 5 6 7 8 下一页 尾页 6/8/8
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Android---闪频页和倒计时 下一篇微信支付仅能成功调用一次的问题

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目