3

我有一个多模块项目,其中 app 模块包含我的绑定适配器,而我的功能模块取决于我的 app 模块,因为它是一个动态功能模块。

应用程序(包含绑定适配器)----> 动态功能模块(存在布局)

我在所有模块中都启用了数据绑定和 kapt。

我无法成功构建应用程序。Android Studio 给了我以下错误,

error: cannot find symbol
import com.app.module1.databinding.FeatureItemBindingImpl;

动态功能模块中的布局文件:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <variable
            name="item"
            type="com.app.module1.views.FeatureItem" />

        <variable
            name="clickListener"
            type="com.app.module1.views.FeatureRecyclerViewAdapter.FeatureItemClickListener" />
    </data>

    <com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:layout_margin="10dp"
        app:cardElevation="3dp"
        android:id="@+id/card"
        android:onClick="@{(view) -> clickListener.onClickFeature(view, item)}">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <androidx.appcompat.widget.AppCompatImageView
                android:id="@+id/feature_image"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="7"
                android:scaleType="fitXY"
                app:set_image="@{item.featureImage}"
                tools:src="@color/green_200" />

            <com.google.android.material.textview.MaterialTextView
                android:id="@+id/feature_name"
                style="@style/TextAppearance.MyTheme.Body2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_weight="1"
                android:gravity="center"
                android:text="@{item.featureName.featureTitle}"
                tools:text="Order Pills" />
        </LinearLayout>

    </com.google.android.material.card.MaterialCardView>
</layout>

App模块中的绑定适配器:

@BindingAdapter("set_image")
fun AppCompatImageView.setImageToImageView(@DrawableRes drawable: Int) {
    this.setImageResource(drawable)
}
4

0 回答 0