DataBinding笔记5

数据自动转换

  

        

 
 


@BindingConversion
fun convertDate(date: Date?): String? {
    val sdf = SimpleDateFormat("yyyy-MM-dd", Locale.CHINA)
    return sdf.format(date)
}
@BindingConversion
fun converColor(value: String?): Drawable? {
    return ColorDrawable(Color.parseColor(value))
}


        bindingBinding.time= Date()
        bindingBinding.bg="#ffeeff"

你可能感兴趣的:(DataBinding笔记5)