0

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

@ZeeBmChan your welcome, please mark this as an answer, so that this can help others!
what is this 1.0-rc3 1.0-rc4? There is no dependency. We only need to mark android.buildFeatures.dataBinding to true in gradle
Please check the date. This is a really old question & answer. At that time, we don't have the option you mentioned, and the lib is not mature enough

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.