无法识别Android自定义库模块BindingAdapter属性

时间:2020-11-09 16:04:26

标签: android android-databinding android-library jitpack android-binding-adapter

所以我刚刚学习了如何通过Github和JitPack发布自己的库(只是一些实用程序函数),这是我的代码:

https://github.com/xht418/Util-Kotlin/tree/main/utlikotlin/src/main/java/com/example/utlikotlin

我的问题是Double.roundDecimal()被识别,但是我的自定义DataBinding属性isAddCase无法被识别,显示AAPT: error: attribute isAddCase (aka com.example.shapeableimageviewtest:isAddCase) not found.

我尝试了一个新项目:

<layout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <data>
        <variable
            name="name"
            type="String" />

    </data>

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

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@{name}"
            app:isAddCase="true"/>    //either "isAddCase" or "app:isAddCase", doesn't work

    </LinearLayout>

</layout>

1 个答案:

答案 0 :(得分:1)

您必须将app:isAddCase=true更改为app:isAddCase="@{true}"

相关问题