How to Handle the checkbox ischecked and unchecked event in android

后端 未结 5 1664
慢半拍i
慢半拍i 2021-01-16 02:11

i am new in android.i make a simple maths apps. i use the check box for select right option but problem is here the answer option is not only one but also two,three means

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-16 02:41

    chk.setOnCheckedChangeListener(new OnCheckedChangeListener() {
    
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    // TODO Auto-generated method stub
    
                          if(isChecked){
                              chetimeslot = (String)chk.getTag();
                                checkbox_timeslot.add(chetimeslot);
    
                            }
                           else{
                               chetimeslot = (String)chk.getTag();
                                checkbox_timeslot.remove(chetimeslot);
    
    
                           }
    
    });
    

提交回复
热议问题