Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Databinding Compile Warning: Method references using '.' is deprecated

I see the following compiler warning when building my project:

warning: Method references using '.' is deprecated. Instead of 'item.onCardClicked', use 'item::onCardClicked'

I am using android plugin for gradle 2.1.0.

My layout file looks like the following:

<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>

Can someone point me to the right direction to resolve this warning?

like image 866
WindsurferOak Avatar asked May 10 '16 23:05

WindsurferOak


1 Answers

Per the error message:

warning: Method references using '.' is deprecated. Instead of 'item.onCardClicked', use 'item::onCardClicked'

So replace @{item.onCardClicked} with @{item::onCardClicked}

like image 193
ianhanniballake Avatar answered Nov 18 '22 08:11

ianhanniballake