Context in Android Databinding XML files

It is so easy guys, just don’t forget that DataBinding creates a field called context which you can access by default in your XML file. So you can write something like this:

   <variable name="name" type="String"/>
      app:text="@{StringUtils.format(context, name)}" />

And it will be just fine. You have the context from the parent view. Check it HERE.

One thought on “Context in Android Databinding XML files

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s