lundi 11 octobre 2021

why checkbox listener method called not working?

In the below code i wish to call afterscan method only when the checkboxer checkbox is clicked. but some how i have noticed that the method is called from all other checkbox once is checked. any help would be highly appreciated

class Chk_class implements CompoundButton.OnCheckedChangeListener{

    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

        result=new StringBuilder();

        if(checkBox2.isChecked())
        {
            result.append("Connection issue |");
        }
  
        if(checkBox4.isChecked())
        {
            result.append("Machnical issue |");
        }
        Toast toast = Toast.makeText(getApplicationContext(), result.toString(), Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.TOP, 0, 0);
        toast.show();
        liftError=result.toString();

        if(checkBoxer.isChecked()){

            afterscan();  // this method is called from all other checkbox as well 
        }


    }
}



Aucun commentaire:

Enregistrer un commentaire