Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visibility Not working with Kotlin

Tags:

android

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
}
like image 812
blesson Samuel Avatar asked Jun 01 '17 19:06

blesson Samuel


2 Answers

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
}
like image 124
AlexTa Avatar answered Sep 28 '22 23:09

AlexTa


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

like image 41
Gourav Samre Avatar answered Sep 28 '22 23:09

Gourav Samre