数据绑定Android Studio Gradle 3.0.1

时间:2018-09-19 07:06:59

标签: android android-gradle android-databinding

自从将我的gradle从2.2.3更新到3.0.1以来,数据带已在错误的位置生成了BR类,导致找不到符号类BR

public abstract class BaseBindingFragment<T, K extends ViewDataBinding> extends BaseFragment<T> {

protected K mBinding;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    mBinding = DataBindingUtil.inflate(inflater, getLayoutResourceId(), container, false);
    mFragmentRootView = mBinding.getRoot();

    // Setup references to views within this fragment
    ButterKnife.bind(this, mFragmentRootView);
    initWidgets(mFragmentRootView);

    return mFragmentRootView;
  }
}

<data>
    <variable
        name="handler"
       type="com.mypackage.fragments.EditBillPaymentsFragment" />

    <variable
        name="billpayment"
        type="com.mypackage.database.models.Bills" />

</data>

            <EditText
                android:id="@+id/et_account_number"
                style="@style/editBill"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="10"
                android:enabled="false"
                android:inputType="textPersonName"
                android:text="@={billpayment.payee.accountNumber}" />

1 个答案:

答案 0 :(得分:0)

BR文件生成于

com.yourpackage.BR;

因此,如果您导入错误,请进行更改。

import com.yourpackage.BR;