The above example works properly, because release 1.0-rc4 fixed the issue of needing the unnecessary variable.
Just set
idto included layout, and usebinding.includedLayout.anyView.
This example helps passing a value to
You have layout_common.xml, want to pass String to included layout.
You will create String variable in layout and refer this String to TextView.
// declare fields
//set field to your view.
Include this layout to parent layout. Give an id to included layout, so that we can use that in binding class. Now you can pass String passedText to your
activity_main.xml
binding.includedLayout.textView in your class.You can pass any variables to included layout like above.
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
binding.includedLayout.textView.setText("text");
Note Both layouts (parent & included) should be binding layout, wrapped with