Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Kotlin check if any CheckBox isChecked

Is there a simple way of making this? I have around 16 of these CheckBoxes.

 kartBox1.setOnClickListener{
            if(kartBox1.isChecked){kartBox1.setBackgroundResource(R.drawable.check_button_checked)}
            else{kartBox1.setBackgroundResource(R.drawable.check_button_unchecked)}}
    kartBox2.setOnClickListener{
            if(kartBox2.isChecked){kartBox2.setBackgroundResource(R.drawable.check_button_checked)}
            else{kartBox2.setBackgroundResource(R.drawable.check_button_unchecked)}}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can basically create list of those buttons and loop through it with foreach and add listeners with all needed checks.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading