How to set click listener to LinearLayout using data binding

后端 未结 3 599
独厮守ぢ
独厮守ぢ 2021-02-15 12:39

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 wo

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-15 13:11

    So everything was set up correctly and the generated bindings file shows the click listener being set up correctly, but for some very odd reason half the bindings were working and the newer ones weren't. By newer ones meaning the LinearLayout and all the attempts around it.

    What solved the problem was a simple cache invalidation and respective restart and voila, the click listener is working perfectly on the LinearLayout. Just remember to set it clickable and focusable and any child views set as not clickable so they don't consume the event before the parent.

    3 entire days around this one, took less than 10 minutes discussing with others here in the comments to remember trying to invalidate the cache of Android Studio, unbelievable of me...

提交回复
热议问题