LoginSignup
36
27

More than 5 years have passed since last update.

DataBindingで引数にcontextを渡すメソッドを扱う

Posted at

DataBindingを使うと、xml内でtextやsrcをバインドできます。

<TextView
    android:text="@{user.name}" />

Contextを引数に持つメソッドを扱いたい場合は、 context とそのまま渡せば動作します。

<TextView
    android:text="@{user.getTranslatedName(context)}" />

以上です。

36
27
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
36
27