Slide 13
Slide 13 text
DataBindingUtil
● It generates Binding class
● Binding class wires up layout
properties to layout views
● Binding class is generated
based on the name of layout
file, starting it with upper-case,
removing underscores ( _ ) and
capitalizing the following letter
and then suffixing “Binding”
● After generating the class, you
can simply set the data with
setter method of Binding class.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MainActivityBinding binding =
DataBindingUtil.setContentView(this, R.layout.main_activity);
User user = new User("Test", "User");
binding.setUser(user);
}