Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
535 views
in Technique[技术] by (71.8m points)

android - Cannot find the setter for attribute with parameter

I am working on DataBinding with BindingAdapter. Here is my custom method.

@BindingAdapter("{bind:fadevisible}")
public static void setFadeVisible(LinearLayout view, int visible) {
    Log.e("Bindings", "setFadeVisible: ");
}

And in xml file i am calling it like

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:fadevisible="@{1}"/>

But it is showing error

Error:Execution failed for task ':app:compileDebugJavaWithJavac'. java.lang.RuntimeException: Found data binding errors. ****/ data binding error ****msg:Cannot find the setter for attribute 'app:fadevisible' with parameter type int on android.widget.LinearLayout. file:appsrcmain es-mainlayoutactivity_detail.xml loc:236:31 - 236:54 **** data binding error ****

I have checked this and this thread but somehow it is not helping me, as you can see i am passing int from xml and in BindingAdapter also i have mentioned LinearLayout with int value.

Even i have another method, where just parameters are different and its working fine

@BindingAdapter({"bind:image_round"}) 
public static void loadRoundImage(ImageView imageView, String url)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Make sure in app level gradle, you have apply plugin: 'kotlin-kapt'


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...