Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如果数据绑定中没有属性命名空间,intellisense将无法工作_Android_Android Studio_Android Databinding - Fatal编程技术网

Android 如果数据绑定中没有属性命名空间,intellisense将无法工作

Android 如果数据绑定中没有属性命名空间,intellisense将无法工作,android,android-studio,android-databinding,Android,Android Studio,Android Databinding,有一个非常简单的bindingadapter函数 @JvmStatic @BindingAdapter("app:test") fun testBind(v: View, test: Int) { //test... } 如果在xml中应用此代码,它通常如下所示: 自动完成功能工作正常,xml不会打印任何警告 但是,此bindingadapter函数在编译时输出警告 warning: Application namespace for attribute app:test will

有一个非常简单的bindingadapter函数

@JvmStatic
@BindingAdapter("app:test")
fun testBind(v: View, test: Int) {
    //test...
}
如果在xml中应用此代码,它通常如下所示:

自动完成功能工作正常,xml不会打印任何警告

但是,此bindingadapter函数在编译时输出警告

warning: Application namespace for attribute app:test will be ignored.
许多其他帖子说删除此警告的名称

我从bindingadapter函数中删除了名称空间

@JvmStatic
@BindingAdapter("test")
fun testBind(v: View, test: Int) {
    //test...
}
这样做不会在编译时打印警告

warning: Application namespace for attribute app:test will be ignored.
但这一次,xml打印了一条警告

另外,当名称空间存在时,正常工作的autocomplete函数根本不工作

在我尝试过的所有方法中,解决所有两个警告的唯一方法是将名称空间指定为android


还有别的办法吗?android名称空间似乎是一个误解,因为这是android中的一个基本绑定功能,而不是自定义绑定函数。

如果在绑定适配器方法中使用单参数,请删除@BindingAdapter(…)字符串中的名称空间,然后在xml中调用字符串之前添加bind:namespace

@JvmStatic
@BindingAdapter("app:test")
fun testBind(v: View, test: Int) {
    //test...
}
 @JvmStatic
@BindingAdapter("icon")
fun setImage(view: ImageView, imageID: Int) {
}
bind:icon=“@{vm.iconID}”


如果我使用了多个属性,它就不起作用。

如果在绑定适配器方法中使用单个参数,请删除@BindingAdapter(…)字符串中的名称空间,然后在xml中调用字符串之前添加bind:namespace

 @JvmStatic
@BindingAdapter("icon")
fun setImage(view: ImageView, imageID: Int) {
}
bind:icon=“@{vm.iconID}”

如果我使用了多个属性,它就不起作用