blesson Samuel
blesson Samuel

Reputation: 421

Visibility Not working with Kotlin

Hi the Given below is my Code, where my button should become INVISIBLE but the INVISIBLE is not working

fun onPlay(view: View){
         var play = findViewById(R.id.play) as Button
         play.isClickable=false
         play.visibility=view.INVISIBLE
}

Upvotes: 15

Views: 32194

Answers (2)

Gourav Samre
Gourav Samre

Reputation: 132

use play.visibility=View.VISIBLE to visible and play.visibility=View.GONE to invisible or to hide

Upvotes: 5

AlexTa
AlexTa

Reputation: 5251

You have a mistake in your code, visibility constant should be set from Class variable, not from argument variable. Change view.INVISIBLE by View.INVISIBLE

fun onPlay(view: View){
     var play = findViewById(R.id.play) as Button
     play.isClickable=false
     play.visibility= View.INVISIBLE // v letter should be capital
}

Upvotes: 38

Related Questions