Having a button appear when a Text Input field is not empty (Kotlin in Android)

Clash Royale CLAN TAG#URR8PPPHaving a button appear when a Text Input field is not empty (Kotlin in Android)
I am trying to enable a button on entering text in an input field. Something similar to this:
Enable a button on entering text in input field
...but in Kotlin.
My current code looks like :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
listOf(textInput1, textInput2, textInput3).map {
it.setOnEditorActionListener() { v, _, _ ->
showButtons(it)
true
}
}
}
and the function is empty:
fun showButtons(textInputHolder: TextInputEditText){
if (textInputHolder == textInput1 || textInput2) {
button1.visibility = View.VISIBLE
} else {
button2.visibility = View.VISIBLE
}
}
Basically, I want to show different buttons depending on which one of the list(textInput1, textInput2, textInput3) is being edited.
Thanks,
F
@Henry I edited the question. Something like what I have shown, but the current code doesn't work
– FerasAS
1 min ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
An empty function will obviously not work. What's the exact problem you are facing when writing it.
– Henry
28 mins ago