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

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Having 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





An empty function will obviously not work. What's the exact problem you are facing when writing it.
– Henry
28 mins ago





@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.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived