Java 多重数据绑定错误
每当我重建项目时,总是会遇到这个错误Java 多重数据绑定错误,java,android,android-layout,data-binding,Java,Android,Android Layout,Data Binding,每当我重建项目时,总是会遇到这个错误 ****/ data binding error ****msg:Multiple binding data tags in C:\Users\Tai\AndroidStudioProjects\Rxjava2Practice2 - Copy\app\src\main\res\layout\item_movie.xml. Expecting a maximum of one. file:C:\Users\Tai\AndroidStudioProjects
****/ data binding error ****msg:Multiple binding data tags in
C:\Users\Tai\AndroidStudioProjects\Rxjava2Practice2 -
Copy\app\src\main\res\layout\item_movie.xml. Expecting a maximum of one.
file:C:\Users\Tai\AndroidStudioProjects\Rxjava2Practice2 -
Copy\app\src\main\res\layout\item_movie.xml
****\ data binding error ****
有时,ItemMovieBinding
不像往常那样自动生成,但在我重新启动android studio之后,它又可以正常工作了
这是我的item_movie.xml
,我尝试过清理、重建或重启android studio,但没有任何效果
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bind="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="result"
type="com.example.tai.rxjava2practice2.Model.Result"></variable>
</data>
<data>
<variable
name="image"
type="com.example.tai.rxjava2practice2.Model.Image"></variable>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_MovieName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_Avatar"
android:layout_weight="1"
android:text="@{result.title}"
android:textSize="16dp" />
<TextView
android:id="@+id/tv_ReleaseDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/iv_Avatar"
android:layout_weight="1"
android:gravity="right"
android:text="@{result.releaseDate}"
android:textSize="16dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/iv_Avatar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="@{image.imageUrl}" />
</LinearLayout>
</LinearLayout>
提前感谢:D您应该只使用一个数据标签,如下所示
<data>
<variable
name="result"
type="com.example.tai.rxjava2practice2.Model.Result"></variable>
<variable
name="image"
type="com.example.tai.rxjava2practice2.Model.Image"></variable>
</data>
您的结束标签在哪里?很乐意帮忙。那么你的问题是什么呢?我的activity_main.xml不生成ActivityMainBinding它还包括数据选项卡和xmlns:bind=“”,但我不能使用ActivityMainBinding,我忘了什么吗?似乎没有足够的信息来找出根案例,我无法在我的注释中添加更多代码,你应该为此问题创建一个新问题我找到答案,只需将activity_main重命名为main_activity,自动生成的类就可以正常工作,tks u for support:D