I have this code that is supposed to make an image visible, but I don't know exactly how it's supposed to be written for Kotlin.
I'm trying to use .visibility
in Kotlin, and I don't know what to give it for a value. It's based off of setVisibility()
.
Code:
fun hacerVisibleLaFoto(v: View) {
imageView.visibility = 1;
}
I put 1
in the value spot because an integer value is required there, and that's my placeholder value until I find what really goes there.
What should go after the =
sign to make the value visible?
Android has static constants for view visibilities. In order to change the visibility programmatically, you should use View.VISIBLE
, View.INVISIBLE
or View.GONE
.
Setting the visibility using myView.visibility = myVisibility
in Kotlin is the same as setting it using myView.setVisibility(myVisibility)
in Java.
In your case:
fun hacerVisibleLaFoto(v: View) {
imageView.visibility = View.VISIBLE
}