LoginSignup
4
1

More than 5 years have passed since last update.

DataBindingでカスタムセッターに定数を指定する場合にattributeがnot foundになる場合の対処

Posted at

カスタムセッターで以下みたいなセッターを作り、param2をXML側で定数にしようとした時にハマった。

@BindingAdapter("app:param1", "app:param2")
@JvmStatic
fun setParam(view: View, param1: Int?, param2: Int?) {
  // いい感じにモニョモニョする
}

xmlで指定する場合は app:param2="123" みたいないつも通りなやり方じゃなくて
ちゃんとデータバインディングのお作法の app:param2="@{123}" と指定する必要がある

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1