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   解決報警問題

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