By default, a Binding class is generated based on the name of the layout file, starting it with upper-case, removing underscores ( _ ) and capitalizing the following letter and then suffixing “Binding”.
This class will be placed in a databinding package under the module package.
For example, the layout file contact_item.xml
will generate ContactItemBinding
.
If the module package is com.example.my.app
, then it will be placed in com.example.my.app.databinding
.
Binding classes may be renamed or placed in different packages by adjusting the class attribute of the data element. For example:
<data class="ContactItem">
...
</data>
This generates the binding class as ContactItem
in the databinding package in the module package. If the class should be generated in a different package within the module package, it may be prefixed with “.”
:
<data class=".ContactItem">
...
</data>
In this case, ContactItem
is generated in the module package directly. Any package may be used if the full package is provided:
<data class="com.example.ContactItem">
...
</data>
MainActivity.java
– Devaluation