As George Mount said starting from 1.0-rc4 we no longer need the variable in include when using data binding:
buttons.xml:
<layout xmlns:andr...>
<Button
android:id="@+id/button"
...." />
main.xml:
<layout xmlns:andr...
...
<include layout="@layout/buttons"
android:id="@+id/buttons"/>
....
But I tried it and get error:
Error:(10, 31) Identifiers must have user defined types from the XML file. toolbarViewModel is missing it
I have the included toolbar:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data class="LoginPhoneFragmentBinding">
<variable
name="toolbarViewModel"
type="ru.mobileup.myalarm2.binding.ToolbarViewModel"/>
</data>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/toolbar"
android:id="@+id/toolbarBinding"/>
And toolbar layout is:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/primary"
android:theme="@style/ToolbarThemeOverlay"
app:navigationIcon="@{toolbarViewModel.navigationIconResId}"
app:navigationOnClickListener="@{toolbarViewModel.navigationOnClickListener}"
app:title="@{toolbarViewModel.title}"
app:menu="@{toolbarViewModel.menuResId}"
app:menuListener="@{toolbarViewModel.onMenuItemClickListener}"/>
What is wrong?
Note: I know that with passed variable all works fine. I trying to figure out how use that George mentioned.