找不到属性';android:tag';-安卓

找不到属性';android:tag';-安卓,android,android-databinding,Android,Android Databinding,我正在使用数据绑定,这里我遇到了这个问题: Error:(252, 21) Cannot find the getter for attribute 'android:tag' with value type java.lang.String on com.hdfcfund.investor.views.EditText. 虽然文本属性工作正常,但在使用标记元素时出错 <?xml version="1.0" encoding="utf-8"?> <layout xmlns:

我正在使用数据绑定,这里我遇到了这个问题:

Error:(252, 21) Cannot find the getter for attribute 'android:tag'
with value type java.lang.String on com.hdfcfund.investor.views.EditText. 
虽然文本属性工作正常,但在使用标记元素时出错

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>

    <variable
        name="presenter"
        type="com.hdfcfund.investor.folio.step4addnominee.AddNomineePresenter" />

    <variable
        name="nominee"
        type="com.hdfcfund.investor.folio.step1.model.NewInvestorFolioRequest.Nominee" />
</data>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:clickable="true">

                <com.hdfcfund.investor.views.EditText
                    android:id="@+id/et_country"
                    style="@style/EditTextStyleRegularGrey15"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:drawableRight="@drawable/ic_arrow_input"
                    android:focusableInTouchMode="false"
                    android:hint="@string/label_country_1"
                    android:inputType="text"
                    android:onClick="@{()-> presenter.onSpinnerClick(spinnerCountry)}"
                    android:tag="@={nominee.nomineeAddress.countryCode}"
                    android:text="@={nominee.nomineeAddress.countryName}" />


</RelativeLayout>
</layout>

您需要定义
@InverseBindingAdapter
以从属性返回值:

@InverseBindingAdapter(attribute = "android:tag")
public static String getStringTag(EditText view) {
    return String.valueOf(view.getTag());
}

您需要定义
@InverseBindingAdapter
以从属性返回值:

@InverseBindingAdapter(attribute = "android:tag")
public static String getStringTag(EditText view) {
    return String.valueOf(view.getTag());
}

默认情况下,
android:tag
属性不支持双向绑定。这是因为在属性更改时没有要通知的事件机制

您可能打算使用单向绑定:

android:tag="@{nominee.nomineeAddress.countryCode}"

用户无法更改标记值,因此双向实际上对该属性没有多大用处。

默认情况下,
android:tag
属性不支持双向绑定。这是因为在属性更改时没有要通知的事件机制

您可能打算使用单向绑定:

android:tag="@{nominee.nomineeAddress.countryCode}"

用户无法更改标记值,因此无论如何,双向对该属性没有多大用处。

我建议使用
String.valueOf()
而不是强制转换。我建议使用
String.valueOf()
而不是强制转换。