首页 > 其他分享 >每日总结2023/3/10

每日总结2023/3/10

时间:2023-03-10 19:57:03浏览次数:45  
标签:总结 10 findViewById cb id isChecked 2023 new CompoundButton

今天学习了AS中的复选框按钮

效果如下

 

 

tv_text = findViewById(R.id.tv_text);
        bt_fa = findViewById(R.id.bt_fa);
        cb_sing = findViewById(R.id.cb_main_sing);
        cb_tiao = findViewById(R.id.cb_main_tiao);
        cb_rap = findViewById(R.id.cb_main_rap);

        bt_fa.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, MainActivity2.class);
                Bundle bundle = new Bundle();
                bundle.putString("request_time", Time_now.getNowTime());
                bundle.putString("request_content", tv_text.getText().toString());
                intent.putExtras(bundle);
                startActivity(intent);
            }
        });
        cb_sing.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                checkedArray[0] = isChecked;
            }
        });

        cb_tiao.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                checkedArray[1] = isChecked;
            }
        });
        cb_rap.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                checkedArray[2] = isChecked;
            }
        });

界面代码

 

<CheckBox
        android:id="@+id/cb_main_sing"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:text="唱"
        android:textSize="16dp" />


    <CheckBox
        android:id="@+id/cb_main_tiao"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="跳"
        android:textSize="16dp" />

    <CheckBox
        android:id="@+id/cb_main_rap"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="rap"
        android:textSize="16dp" />

 

标签:总结,10,findViewById,cb,id,isChecked,2023,new,CompoundButton
From: https://www.cnblogs.com/JJTyyds/p/17204514.html

相关文章

  • 【2023-03-10】心虚指引
    18:00人表达的爱越多,别人就越爱他,别人越爱他,他也更容易爱别人。爱就是以此方式变成永恒。                        ......
  • 2023.3.10
    这几天讲的倍增捏(一开始以优化dp为主,现在几乎纯倍增,6)。然后发现我不会快速幂。LuoguP1226.【模板】快速幂||取余运算 传送门我们知道任意整数可以表示成若干个2的......
  • 10分钟快速掌握分布式版本控制系统GIT命令集【形成知识体系篇】
    任务要求要求全部使用git命令实现1、创建本地仓库,项目名称为hniu_site2、在仓库下创建多级(目录)文件夹cn/hniu/班级名称(例如软件2108,cn/hniu/rj2108)3、在班级名称下新......
  • python 基础230310
    变量的命名规则:字母数字下划线/不能以数字开头/不能使用关键字/不能使用中文,要肯有描述性,不能过长驼峰体:AgeOfOld下划线:age_of_old_boy变量指向:变量在......
  • 利民发布 HR-10 2280 M.2 SSD 散热器,搭载双 AGHP 逆重力热管
    3月10日消息,利民现已发布新款HR-102280M.2SSD散热器,售价79元。据官方介绍,Thermalright利民HR-102280散热器采用了高质感电镀回流焊技术,采用大面积散热片,内......
  • 2023-03-10 Java中使用ArrayDeque实现栈和队列
    栈和队列的实现实际上完全可以用JDK自带的类ArrayDeque来实现作为队列使用publicabstractbooleanadd(EparamE);//加入元素到队尾publicabstractbooleanoffe......
  • ES6-ES11 ES10-Symbol.prototype.description
    原视频<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title......
  • 10进制小数如何转化为2进制
    方法:乘二取整法,将10进制数字的小数部分乘以2,取得到数字的整数部位作为小数部分二进制的第一位,一直到小数为0为止例如:8.125,整数部分的二进制为1000,小数部分为0.125,0.125第一......
  • ES6-ES11 ES10字符串方法扩展-trimStart-trimEnd
    原视频<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title......
  • ES6-ES11 ES10数组方法扩展-flat与flatMap
    原视频<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title......