databinding 自定义控件设置属性遇到的问题 原

Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > android.databinding.tool.util.LoggedErrorException: Found data binding errors. ****/ data binding error ****msg:Cannot find the setter for attribute 'app:show_value' with parameter type int on com.yarui.app.client.ui.view.lcfengview.AddSubtractLinearLayout. file:E:\work_space\aa\app\src\main\res\layout\activity_plan_add_edit.xml loc:208:46 - 208:63 ****\ data binding error ****

 

当你遇到上述问题的时候,应更是你没有设置set 属性操作,例如下面:

@BindingAdapter({"show"})   

public static void setText(View textView, String user) {

    textView.setText(user);

}

  --->请注意BindingAdapter括号里面还有一个花括号呢,这个对应的就是你的布局文件中的 app:show="hello" 属性哦

参考:https://medium.com/androiddevelopers/android-data-binding-custom-setters-55a25a7aea47  解决报错问题

          https://blog.csdn.net/csc48656/article/details/73009398   解决报警问题

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章