Last active
April 15, 2019 13:08
-
-
Save liangfeidotme/cc5b3af06a2a71039f20 to your computer and use it in GitHub Desktop.
Use Android Data Binding with include tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:bind="http://schemas.android.com/apk/res-auto"> | |
<data> | |
<import type="com.liangfeizc.databindingsamples.basic.User" /> | |
<variable | |
name="user" | |
type="User" /> | |
<variable | |
name="contact" | |
type="com.liangfeizc.databindingsamples.custombindings.Contact" /> | |
</data> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical"> | |
<include | |
layout="@layout/user" | |
bind:user="@{user}" /> | |
<include | |
layout="@layout/contact" | |
bind:contact="@{contact}" /> | |
</LinearLayout> | |
</layout> |
It'd be great if u can show the included layout.
Please can you add contact.xml and user.xml?
I am trying the same thing but cant seem to nail it.
This article shows a way to pass variables to an <include>
'd layout.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I cannot figure out how to set the binding when using
<include ... />
. I meant the java part of data binding. Can you help me please?