• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
起个名太难了
博客园    首页    新随笔    联系   管理    订阅  订阅
每日日报

今日代码

public class MainActivity extends AppCompatActivity{
//CheckBox复选框
private CheckBox check1;
private CheckBox check2;
private CheckBox check3;
private CheckBox check4;
private CheckBox check5;
private String str="特殊情况:";
//提交按钮
private Button mBtnSubmit;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

//CheckBox复选框
check1=findViewById(R.id.instruction1);
check2=findViewById(R.id.instruction2);
check3=findViewById(R.id.instruction3);
check4=findViewById(R.id.instruction4);
check5=findViewById(R.id.instruction5);

//提交按钮
mBtnSubmit = findViewById(R.id.btn_submit);
mBtnSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

//复选框
if(check1.isChecked()){
str+=check1.getText()+",";
}
if(check2.isChecked()){
str+=check2.getText()+",";
}
if(check3.isChecked()){
str+=check3.getText()+",";
}
if(check4.isChecked()){
str+=check4.getText()+",";
}
if(check5.isChecked()){
str+=check5.getText()+",";
}
Toast.makeText(MainActivity.this,str,Toast.LENGTH_LONG).show();
}
}

 

posted on 2021-11-22 20:17  起个名太难了  阅读(18)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3