【发布时间】:2017-01-19 14:46:07
【问题描述】:
我有以下非常简单的布局,并想切换到使用数据绑定。现在我的controller_main.xml 出现以下错误:
Error:Execution failed for task ':app:dataBindingProcessLayoutsDebug_pro'.
****/ 数据绑定错误 ****msg:[44 68 44 68 25] 必须包含布局 文件:...\app\src\main\res\layout\controller_main.xml ****\数据绑定错误****
有什么想法吗?错误说,include 标签中的资源android:layout id 丢失(这是我对错误的解释),但事实并非如此。注释掉 include 标记可以消除错误。
有人发现问题了吗?
controller_main.xml
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
android:fitsSystemWindows="true"
android:background="?attr/main_background_color"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/rlContent"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
</RelativeLayout>
<include
android:layout_width="fill_parent"
android:layout_height="@dimen/tool_bar_top_padding"
android:id="@+id/stub_view_main_header_fixed"
android:layout="@layout/view_main_header_fixed"
app:elevation="0dp"/>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
</layout>
view_main_header_fixed.xml
<?xml version="1.0" encoding="utf-8"?>
<View
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/vStatusbarBackground"
android:layout_width="match_parent"
android:layout_height="@dimen/tool_bar_top_padding" />
【问题讨论】:
-
"id in the include tag is missing",这有什么不清楚的地方? -
你看到包含了吗?它正在定义一个id。而且我不知道你从哪里得到
"id in the include tag is missing"...它说布局丢失。但是布局也被定义了。反正问题已经解决了……
标签: android data-binding android-databinding