Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android数据绑定编译警告:方法引用使用'';不赞成_Android_Android Gradle Plugin_Android Databinding - Fatal编程技术网

Android数据绑定编译警告:方法引用使用'';不赞成

Android数据绑定编译警告:方法引用使用'';不赞成,android,android-gradle-plugin,android-databinding,Android,Android Gradle Plugin,Android Databinding,在生成项目时,我看到以下编译器警告: 警告:不推荐使用“.”的方法引用。不要使用“item.oncardclicated”,而是使用“item::oncardclicated” 我正在为Gradle2.1.0使用android插件 我的布局文件如下所示: <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-au

在生成项目时,我看到以下编译器警告:

警告:不推荐使用“.”的方法引用。不要使用“item.oncardclicated”,而是使用“item::oncardclicated”

我正在为Gradle2.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>

...
有人能告诉我解决此警告的正确方向吗?

根据错误消息:

警告:不推荐使用“.”的方法引用使用“item::oncardclicated”代替“item.oncardclicated”


因此,将
{item.oncardclicated}
替换为
{item::oncardclicated}

Android数据绑定的Android文档中没有提到Java的方法引用操作符,所以我犹豫是否采用它。看来今后,这将是使用的惯例。再次感谢。请注意,Android Studio可能不支持此符号,因此在编辑文件时可能会出现红色的波形。Android Studio 2.1.3不喜欢布局编辑器中的“:”符号(但仍然构建了项目)。Android Studio 2.2.0仍然不喜欢布局编辑器中的“:”。爆笑!!我想我会用点符号代替::因为我不喜欢在文件中看到错误标记,而且我可以更容易地从心理上忽略gradle警告。Android Studio 2.2.2也是如此。“::”显示为错误,但项目生成,没有生成警告。试图在AS首选项中找到正确的检查,但没有(至少我可以看到…)