如何将数据绑定到kotlin中的imageview?
<ImageView
app:photoFilePath="@{item.photoFilePath}"
android:layout_width="60dp"
android:layout_height="60dp"
/>
这是我的课程:
class OrderInfoFragment : BaseDialogFragment() {
private lateinit var mOrderItem: OrderItem
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val inflater = activity.layoutInflater
val binding = DataBindingUtil.inflate<FragmentOrderInfoBinding>(
inflater, R.layout.fragment_order_info, null, false)
val view = binding.root
binding.item = mOrderItem
}
@BindingAdapter("bind:photoFilePath")
fun loadPhotoFilePath(imageView: ImageView, path: String) {
}
}
我尝试在随播对象中使用loadPhotoFilePath
。
答案 0 :(得分:1)
功能loadPhotoFilePath
应该在课外,将其置于class OrderInfoFragment
之上。
或者另一种方法是将其注释为@JvmStatic