Android 数据绑定编译警告:使用“.”的方法引用已弃用
Android Databinding Compile Warning: Method references using '.' is deprecated
我在构建项目时看到以下编译器警告:
warning: Method references using '.' is deprecated. Instead of 'item.onCardClicked', use 'item::onCardClicked'
我正在为 gradle 2.1.0 使用 android 插件。
我的布局文件如下所示:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="item"
type="com.example.Card"/>
</data>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:onClick="@{item.onCardClicked}"/>
...
</LinearLayout>
</layout>
有人可以指出解决此警告的正确方向吗?
根据错误消息:
warning: Method references using '.' is deprecated. Instead of 'item.onCardClicked', use 'item::onCardClicked'
所以用@{item::onCardClicked}
替换@{item.onCardClicked}
我在构建项目时看到以下编译器警告:
warning: Method references using '.' is deprecated. Instead of 'item.onCardClicked', use 'item::onCardClicked'
我正在为 gradle 2.1.0 使用 android 插件。
我的布局文件如下所示:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="item"
type="com.example.Card"/>
</data>
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:onClick="@{item.onCardClicked}"/>
...
</LinearLayout>
</layout>
有人可以指出解决此警告的正确方向吗?
根据错误消息:
warning: Method references using '.' is deprecated. Instead of 'item.onCardClicked', use 'item::onCardClicked'
所以用@{item::onCardClicked}
@{item.onCardClicked}