I am currently trying to set a click listener to a LinearLayout
view in the .xml
layout file using data binding.
I have managed to get it to work well on other views like a Button
or TextView
, but for some reason it is not working with a LinearLayout
.
This is the bare bones of my attempts and I still cannot get it to work:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="72dp"
android:clickable="true"
android:focusable="true"
android:onClick="@{action::linearLayoutClicked}"
android:orientation="vertical">
</LinearLayout>
Where linearLayoutClicked
is my method defined in the action class:
public void linearLayoutClicked(View view) {
// specific logic
}
I have also tried with child views and those child views with clickable
and focusable
set to false as well as duplicateParentState
set to true
and false
.
That action is exactly the same action that is being used on other views which is working correctly.
Is this a bug or am I doing this incorrectly? Why is this not working for LinearLayout
but works without any problems for other views?