Reputation: 59
test.xml:
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/include_content"
layout="@layout/content" />
</FrameLayout>
</layout>
content.xml:
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test button"/>
</FrameLayout>
</layout>
Java Code:
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
TestBinding binding=DataBindingUtil.setContentView(this, R.layout.test);
Button button = binding.includeContent.button;
}
when i run the application , Android studio build error 'cannot find symbol variable includeContent'
what do i miss?
Upvotes: 0
Views: 1721
Reputation: 1179
check this answer.
basically, if you use 1.0-rc3 or below, you need to pass a value to included layout.
if you use 1.0-rc4 or later, it should work without passing a value.
Android Data Binding using include tag
Upvotes: 1