kotlin – Problem with my if statement and operator

Decrease the value of text_amount only if it contains a value greater than 0 and after that check again its value and if it is 0 then hide it:

view.minus_btn.setOnClickListener {
    if (number > 0) {
        number--
        view.text_amount.text = number.toString()      
        if (number == 0) view.text_amount.visibility = View.GONE
    }
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top