我正在使用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")应该可以正常工作.
更多推荐
找不到带有参数的属性的设置器
发布评论