Android Databinding: “Method references using '.' is deprecated”

前端 未结 4 2211
悲哀的现实
悲哀的现实 2021-02-19 07:34

When using databinding in my app, I get the following warning when compiling:

Warning:Method references using \'.\' is deprecated. Instead of \'handler.onItemClick

4条回答
  •  无人及你
    2021-02-19 08:00

    I didn't want to switch off Java 8 so I used the lambda expressions in databinding instead:

    android:onClick="@{(v)->handler.onItemClick(v)}"

    Here is an article by George Mount that gives lots of examples.

    One thing to note is that the lambda expression is bound when the event occurs not at binding time.

提交回复
热议问题