伴生函数定义
class OrderListPageBean{
companion object{
fun test1(num:Int){
}
}
}
在java中使用
OrderListPageBean.Companion.test1(1)
在xml中使用
android:text="@{OrderListPageBean.Companion.test1(1)}"
不过在当前版本,能链接上,但是没法编译通过
得使用object才可以使用
object GoodsConstant{
fun test1(num:Int){
}
}
在xml中使用
android:text="@{GoodsConstant.INSTANCE.test1(1)}"
总结,xml中使用的方法,都是java中调用的方法,所以 遇到不知道怎么在xml写的方法,可以先在java中提示调用,而且有可能像伴生函数,即便是能够链接到,还是无法在dataBinding编译通过。