'Android resource linking failed in binding adapter data binding

I want to set text using binding adapter.Here is the MyBindingAdapter.kt

@BindingAdapter("android:setTitle")
fun setTitle(textView : TextView,text: String){
        textView.text = text
}

in activity_table.xml I used setTitle like this

  <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_column="1"
            android:layout_weight="1"
            android:gravity="center"
            android:setTitle="Hello word"/>

and I getting below error in compile time and I getting below error at compile time



Solution 1:[1]

You need to change from @BindingAdapter("android:setTitle") to @BindingAdapter("setTitle") in your MyBindingAdapter.kt.

Also you need to change in xml file from android:setTitle="Hello word" to setTitle="Hello word"

It should work now!

Solution 2:[2]

First make sure you have to enclose you layout within the <layout> tag

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

and @BindingAdapter("android:setTitle") change as @BindingAdapter("title")

it should work.

Solution 3:[3]

Android studio will not consider @BindingAdapter("android:setTitle") while binding it, you need to write only @BindingAdapter("setTitle") to execute it perfectly, otherwise it will give that binding error while compile time.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 krupa parekh
Solution 2 Sandy
Solution 3 Olle Ekberg