【发布时间】:2018-03-08 09:52:37
【问题描述】:
我的项目中有多个模块,假设模块 app 和模块 A 充当模块 app 的库。我使用数据绑定并通过添加工作正常
dataBinding {
enabled = true
}
在每个模块 build.gradle.
当我使用标签从模块 A 中包含布局时出现问题。当我尝试访问包含布局的数据绑定时,它返回 View 对象而不是 ViewDataBinding
但是,当我尝试继续访问包含布局中的 id 时,即使 IDE 显示错误,编译也可以正常工作。我已经尝试过重建项目、使缓存无效和其他一切。
而且我确信已经遵循了如何实现 DataBinding 的规则。这是模块应用程序的布局:
<layout xmlns:android="http://schemas.android.com/apk/res/android>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/light_gray"
android:orientation="vertical">
<include layout="@layout/included_layout" id="@+id/contact"/>
</LinearLayout>
</layout>
模块 A 的布局:
<layout xmlns:android="http://schemas.android.com/apk/res/android>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/tv_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</layout>
【问题讨论】:
-
IDE 显示什么错误?
-
无法解析符号,基本上是找不到i.stack.imgur.com/afIQX.png
-
您找到解决方案了吗?
-
您找到解决方案了吗? (2)
标签: android android-studio data-binding