I am simply trying to have an onlick listen on an Edit text inside a TextInputLayout. It works but I need to click on the EditText twice for it to trigger I dont understand why.
Set the attribute android:focusableInTouchMode
to false
android:focusableInTouchMode="false"
in your edittext
xml code.
Explanation, as from docs, android:focusableInTouchMode is:
Boolean that controls whether a view can take focus while in touch mode. If this is true for a view, that view can gain focus when clicked on, and can keep focus if another view is clicked on that doesn't have this attribute set to true.
and the EditText
is true by default.
In other words: the first click will make the edittext
to gain focus and second click is the one that triggers the ClickListener
. So you should disable gaining focus on touch.