Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform click on TextInputLayout EndIcon button

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()
like image 914
yaugenka Avatar asked Jan 27 '20 10:01

yaugenka


1 Answers

textinput.setEndIconOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // do some code
            }
        });

hope it helps..

like image 189
Jaydeep chatrola Avatar answered Sep 21 '22 21:09

Jaydeep chatrola