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

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

我正在使用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上找不到参数类型为in的属性"app:fadevisible"的设置器. 文件:\ app \ src \ main \ res-main \ layout \ activity_detail.xml loc: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:\app\src\main\res-main\layout\activity_detail.xml loc:236:31 - 236:54 ****\ data binding error ****

我已经检查了此和此线程,但是以某种方式它对我没有帮助,如您所见我从xml传递int,在BindingAdapter中也用int值提到了LinearLayout.

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

发布评论

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

>www.elefans.com

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