I've this layout:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/input_birthdate"
style="@style/ExposedDropDownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/birthdate">
<AutoCompleteTextView
android:id="@+id/autocomplete_birthdate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:editable="false" />
</com.google.android.material.textfield.TextInputLayout>
With this style:
<!-- ExposedDropdownMenu -->
<style name="ExposedDropDownMenu" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu">
<item name="boxStrokeColor">@color/text_input_layout_outlined_box_stroke</item>
<item name="hintTextColor">@color/green_2</item>
</style>
I've tried to set a click listener on the autocomplete text view:
autoComplete.setOnClickListener(view -> {
// This is called twice when i click the autocomplete textview
});
The listener is called twice...why? How can i solve this?
EDIT: removing the style, the first click (gaining the focus) is ignored, than the second click is called correctly once, but I lose the "ripple" background effect anyway.
You can try the setOnTouchListener instead, it's called just once and keeps the ripple as well.
autocomplete_birthdate.setOnTouchListener { view, motionEvent ->
if (motionEvent.action == ACTION_UP) {
// Some code
}
return false
}
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