Description:
Settings a OnFocusChangeListener on the TextInputEditText inside the TextInputLayout notifies the listener only the very first time the focus is gained.
Expected behavior:
The listener should always fire when focus is gained and lost.
Source code:
textInputEditText.setOnFocusChangeListener { _, hasFocus ->
println("only fires on first focus gained")
}
Android API version: 29
Material Library version: 1.2.0-alpha04
Device: Emulator
Hi, I'm not able to reproduce the issue. Could you provide a sample app?
Ok, closing this issue.
Hi,
I have the same issue here. Why this ticket has been closed ? Is there a fix available ?
Thanks
@kazougagh can you provide a sample app with the issue since it's not reproducible on our end?
Hi @leticiarossi ,
This issue occurs when you try to set the endIconMode programmatically and not using the xml attributes. Like this:
`
val inputLayout = findViewById<TextInputLayout>(R.id.text_input_layout)
inputLayout.editText?.onFocusChangeListener = View.OnFocusChangeListener { _, hasFocus ->
// ----------------------------
// Called on first focus only !
// ----------------------------
Log.d(TAG, "inputEditText - hasFocus $hasFocus")
if (inputLayout.endIconMode == TextInputLayout.END_ICON_NONE) {
inputLayout.endIconMode = TextInputLayout.END_ICON_CLEAR_TEXT
inputLayout.setEndIconTintList(ColorStateList.valueOf(getColor(R.color.colorPrimaryDark)))
}
}`
I have the exact same issue, as described by kazougagh. When setting endIconMode programatically its never called again.
Most helpful comment
I have the exact same issue, as described by kazougagh. When setting endIconMode programatically its never called again.