找不到带参数的属性的设置器

编程入门 行业动态 更新时间:2024-10-10 17:23:12
本文介绍了找不到带参数的属性的设置器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用 BindingAdapter 处理 DataBinding.这是我的自定义方法.

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: "); }

在 xml 文件中我这样称呼它

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}"/>

但是显示错误

错误:任务:app:compileDebugJavaWithJavac"的执行失败.java.lang.RuntimeException:发现数据绑定错误.****/数据绑定错误 ****msg:在 android.widget.LinearLayout 上找不到参数类型为 int 的属性app:fadevisible"的设置器.文件:appsrcmaines-mainlayoutactivity_detail.xml地点:236:31 - 236:54****数据绑定错误****

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:appsrcmaines-mainlayoutactivity_detail.xml loc:236:31 - 236:54 **** data binding error ****

我已经检查了这个和this 线程但不知何故它没有帮助我,正如你所看到的我正在从 xml 和 BindingAdapter 传递 int ,我也提到了 LinearLayout 和 int 值.

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)

推荐答案

你的 @BindingAdapter 定义对我来说有点奇怪

Your @BindingAdapter definition looks a little bit odd to me

@BindingAdapter("{bind:fadevisible}")

这跟不一样

@BindingAdapter({"bind:fadevisible"})

@BindingAdapter("bind:fadevisible")

应该可以正常工作.

更多推荐

找不到带参数的属性的设置器

本文发布于:2023-11-09 03:55:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571330.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:找不到   属性   参数

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!