Android <include> 无法使用 ViewBinding

Android <include> didn't work with ViewBinding

我对此 "new" Android 视图绑定有疑问。当我尝试使用 <include> 时出现异常 在我的 XML-Layout 文件中: <include layout="@layout/teaser_agreement" />

包含文件只是一个基本的布局文件。如果我直接用应该包含的布局代码替换 <include> 标签,一切正常。

这是生成的异常 class:

error: incompatible types: TeaserAgreementBinding cannot be converted to ViewDataBinding
        setContainedBinding(this.mboundView11);

有什么建议吗?

谢谢, 微

您还必须用布局标签包裹 teaser_agreement.xml。所以它会是这样的:

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

<--!Rest of your xml code-->
......
..........
............

</layout>