I know that it is possible to perform a click on a view like this :
view.PerformClick()
How do I do it on TextInputLayout
EndIcon button
?
Update
The problem is that I have a bunch of InputLayouts and use a generic function to set the click listeners on them like so
fun setTextInputLayoutListeners(
inputLayout: TextInputLayout, editText: TextInputEditText,
actionSet: () -> Unit,
actionClear: () -> Unit
) {
with (inputLayout) {
setOnClickListener { actionSet() }
setEndIconOnClickListener { actionClear() }
}
editText.setOnClickListener { actionSet() }
}
and call it with different parameteres like this
setTextInputLayoutListeners(
categoryInputLayout, categoryEditText, { onCategoryClick() }, { onCategoryClear() }
)
setTextInputLayoutListeners(
dateInputLayout, dateEditText, { onDateClick() }, { onDateClear(calendar) }
)
so I'm looking for a generic solution, sort of
inputLayout.EndIcon.PerformClick()
textinput.setEndIconOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// do some code
}
});
hope it helps..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With