Kotlin in Android Studio. I'm trying to change the button text but I'm getting an "exepected a value of type boolean" message. How can I fix this?
button11.setOnLongClickListener{
button11.text = ""
}
The onLongClick
method in the View.OnLongClickListener
interface that you're implementing here via SAM conversion returns a boolean
value, signaling whether you've consumed the long click event.
Therefore, you need to return a Boolean
from your lambda in Kotlin, for example, like this (the last expression of a lambda is returned):
button11.setOnLongClickListener {
button11.text = ""
true
}
Try using not null or safe :
button11?.setOnLongClickListener{
button?.text=""
}