[英]databinding must include a layout file
I have following very simple layout and wanted to switch to using data binding. 我有非常简单的布局,并希望切换到使用数据绑定。 Now I'm getting following error in my
controller_main.xml
: 现在我在
controller_main.xml
遇到以下错误:
Error:Execution failed for task ':app:dataBindingProcessLayoutsDebug_pro'.
****/ data binding error ****msg:[44 68 44 68 25] must include a layout file:...\\app\\src\\main\\res\\layout\\controller_main.xml ****\\ data binding error ****
**** /数据绑定错误****消息:[44 68 44 68 25]必须包含布局文件:... \\ app \\ src \\ main \\ res \\ layout \\ controller_main.xml **** \\ data绑定错误****
Any ideas? 有任何想法吗? The error says, the resource
android:layout
id in the include
tag is missing (that's my interpretation of the error), but that's not true. 错误说,缺少
include
标签中的资源android:layout
id(这是我对错误的解释),但事实并非如此。 Commenting out the include
tag removes the error. 注释掉
include
标记会删除错误。
Does anyone see the problem? 有谁看到这个问题?
controller_main.xml 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 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" />
You should use layout
instead of android:layout
: 你应该使用
layout
而不是android:layout
:
<include
android:layout_width="fill_parent"
android:layout_height="@dimen/tool_bar_top_padding"
android:id="@+id/stub_view_main_header_fixed"
layout="@layout/view_main_header_fixed"
app:elevation="0dp"/>
I had the exact same error, but for a different reason. 我有完全相同的错误,但出于不同的原因。 I was using
<include>
opening tag and </include>
closing tag instead of <include
for opening and />
for closing. 我使用
<include>
开始标记和</include>
结束标记而不是<include
for opening和/>
来关闭。 It's little strange, but anyway your question helped me find my mistake. 这有点奇怪,但无论如何你的问题帮助我找到了我的错误。 Thanks.
谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.