vendredi 21 mai 2021

how to use values generated from if else statment [duplicate]

I am trying to use android-switches for each day of the week in android using kotlin. The way I have it set up, when the user clicks the go button my kotlin checks the position of each of the switches and then generates a value.

        if (view.MON_switch.isChecked){
            val mon = 1
        }else{
            val mon = 0
        }

the problem is that I cannot use the VALue generated outside of the if/else statement. I need to have this value as a VAL so I can put it in an array and export it to a database. if you could either show me a better way of handling switches in android/kotlin or show me how to make the VAL useable later in my code I would be very thankful.

thank you for your time in advance.

Aucun commentaire:

Enregistrer un commentaire