赞
踩
在自定义view 中给attr.xml中自定义属性(book_name)设置 databinding数据之后,编译报错
xxxxx/demo/DataBinderMapperImpl.java:9: 错误: 找不到符号
import xxxx.demo.databinding.ActivityMainBindingImpl;
<com.xxx.CusView
android:id="@+id/cusView"
android:background="#ffffff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:book_name="@{datarepository.bookName}"
/>
在一篇csdn博客中收到启发。kotlin 这边使用attr自定义的属性名引用databinding数据会报错。改成在该自定义view中使用set属性名方式然后引用该属性则不报错
参考https://blog.csdn.net/qq_43522147/article/details/108609491
和那篇博客中问题不同之处在于自定义view那篇是使用自定义布局, 我这里是自绘制的自定义view出的问问题,解决思路和方法是和那篇一样的改使用set属性方式
自定义控件: CusView{
…
//自定义属性名称
var booName: String? = “”
…
}
在xml中使用:
<com.xxx.CusView
app:bookName=“datarepository.bookName”/>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。