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

问题描述

所以我刚刚学习了如何通过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>

解决方法

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...