Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android bindingComponent参数必须是DataBindingComponent的实例_Android_Android Layout_Android Databinding - Fatal编程技术网

Android bindingComponent参数必须是DataBindingComponent的实例

Android bindingComponent参数必须是DataBindingComponent的实例,android,android-layout,android-databinding,Android,Android Layout,Android Databinding,所以我在我的Android项目中使用数据绑定,有一个类有问题 崩溃日志: 提供的bindingComponent参数必须是DataBindingComponent的实例 该项目使用的是Android支持库,而不是Android。生成DatanBinding类时没有问题。下面是代码片段 public BaseBrowserAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { LayoutInflate

所以我在我的Android项目中使用数据绑定,有一个类有问题

崩溃日志:

提供的bindingComponent参数必须是DataBindingComponent的实例

该项目使用的是Android支持库,而不是Android。生成DatanBinding类时没有问题。下面是代码片段

public BaseBrowserAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        LayoutInflater from = LayoutInflater.from(viewGroup.getContext());
        if (i == 32 || i == 128) {
            return new MediaViewHolder(BrowserItemBinding.inflate(from, viewGroup)); //Error at here, BrowserItemBinding
        }
        return new SeparatorViewHolder(BrowserItemSeparatorBinding.inflate(from, viewGroup));
    }
这是浏览器\u item.xml

<?xml version="1.0" encoding="utf-8"?>
<layout>
    <data>
        <import type="android.view.View"/>
        <import type="android.text.TextUtils"/>
        <import type="com.test.media.MediaLibraryItem"/>
        <variable
            name="holder"
            type="com.test.subtitle_browser.BaseBrowserAdapter.ViewHolder"/>
        <variable
            name="item"
            type="MediaLibraryItem"/>
        <variable
            name="title"
            type="String"/>
        <variable
            name="hasContextMenu"
            type="boolean"/>
        <variable
            name="checkEnabled"
            type="boolean"/>
        <variable
            name="checked"
            type="boolean"/>
        <variable
            name="protocol"
            type="String"/>
        <variable
            name="cover"
            type="android.graphics.drawable.BitmapDrawable"/>
        <variable
            name="bgColor"
            type="int" />
    </data>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/background_item"
    android:focusable="true"
    android:minHeight="50.0dip"
    android:padding="2.0dip"

    >

    <CheckBox
        android:id="@+id/browser_checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:checked="false"
        android:focusable="false"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/dvi_icon"
        android:layout_width="50.0dip"
        android:layout_height="50.0dip"
        android:contentDescription="@string/cover_art"
        android:gravity="center"
        android:textColor="@color/whitetransparent"
        android:textSize="11.0sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toEndOf="@+id/browser_checkbox"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/title"
        android:layout_width="0.0dip"
        android:layout_height="wrap_content"
        android:layout_marginStart="5.0dip"
        android:layout_marginLeft="5.0dip"
        android:ellipsize="marquee"
        android:fontFamily="sans-serif-light"
        android:marqueeRepeatLimit="marquee_forever"
        android:maxLines="1"
        android:textColor="?list_title"
        android:textSize="16.0sp"
        app:layout_constraintBottom_toTopOf="@+id/text"
        app:layout_constraintEnd_toStartOf="@+id/item_more"
        app:layout_constraintStart_toEndOf="@+id/dvi_icon"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_chainStyle="packed"
        app:layout_goneMarginBottom="2.0dip" />

    <TextView
        android:id="@+id/text"
        android:layout_width="0.0dip"
        android:layout_height="wrap_content"
        android:ellipsize="marquee"
        android:fontFamily="sans-serif-light"
        android:maxLines="1"
        android:textColor="?list_subtitle"
        android:visibility="gone"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/item_more"
        app:layout_constraintStart_toStartOf="@+id/title"
        app:layout_constraintTop_toBottomOf="@+id/title" />

    <ImageView
        android:id="@+id/item_more"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/ic_more_player"
        android:paddingLeft="10.0dip"
        android:paddingRight="10.0dip"

        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</layout>

事先非常感谢你。如果你需要更多的细节,请告诉我