title: Pass data to <include> layout using Databinding
body: <p>I've been searching this a lot today and only found some unclear answers regarding this question.</p>
  
  <p>I'm having multiple TextView and EditText in a form, all of them being customised by my theme and i'd like to reuse the same included layout each time, but having parameters to it like the text inside the TextView or hint inside the EditText.</p>
  
  <p>My form.xml right now:</p>
  
  <p></p>
  
  <pre><code>&lt;LinearLayout android: orientation="horizontal"&gt;
       &lt;TextView android:text="Username"/&gt;
       &lt;EditText android:id="edittext_username"
                 android:hint="Enter username..."
                 android:inputType="text"/&gt;
  &lt;/LinearLayout&gt;
  
  &lt;LinearLayout android: orientation="horizontal"&gt;
       &lt;TextView android:text="Password"/&gt;
       &lt;EditText android:id="edittext_password"
                 android:hint="Enter password..."
                 android:inputType="password"/&gt;
  &lt;/LinearLayout&gt;
  
  ... other fields ...
  </code></pre>
  
  <p></p>
  
  <p>What i'd like in the main form.xml:</p>
  
  <pre><code>&lt;LinearLayout android:orientation="vertical" ...&gt;
       &lt;include layout="form_edittext" 
              app:textview_text="@{`Username`}"
              app:edittext_hint="@{`Enter username...`}"
              ... other parameters ...
   /&gt;
       &lt;include layout="form_edittext"
              app:textview_text="@{`Password`}"
              app:edittext_hint="@{`Enter password...`}"
              ... other parameters ...
   /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>also the form_edittext.xml:</p>
  
  <pre><code>&lt;layout xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;data&gt;
          &lt;variable name="textview_text" type="java.lang.String"/&gt;
          &lt;variable name="edittext_id" type="java.lang.String"/&gt;
          &lt;variable name="edittext_inputType" type="java.lang.String"/&gt;
          &lt;variable name="edittext_hint" type="java.lang.String"/&gt;
      &lt;/data&gt;
  
      &lt;TextView android:text="@{textview_text}"/&gt;
      &lt;EditText android:id="@{edittext_id}"
                     android:hint="@{edittext_hint}"
                     android:inputType="@{edittext_inputType}"/&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <p>I'm still a beginner and i do not know if this is possible. 
  On this post, the guy replied he used data binding (as in example shown by me)
  <a href="https://stackoverflow.com/questions/36617322/how-to-re-using-layouts-with-include-with-parameters">How to Re-using Layouts with &lt;include/&gt; with parameters?</a> (you may see the first answer).</p>
  
  <p>However, using this method give me the error of XML not recognizing identifiers like "textview_text" (the variables that i'm accessing via @{...}. If you got other solutions i'd appreciate if you share them. Cheers!</p>
  
  <p><strong><em>UPDATE on iCantC's answer:</em></strong> (but the textview's text and the hint remain empty).
  Main layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;layout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"&gt;
  
   ...
              &lt;include layout="@layout/activity_login_layout_input"
                  android:id="@+id/activity_login_layout_input_emailAddress"
                  app:textviewt="@{@string/email}"     //the string is "Email Address"
                  app:edittexth="@{@string/emailhint}" /&gt;     //the string is "Your email address..."
  
   ...
  &lt;/layout&gt;
  </code></pre>
  
  <p>Included layout:</p>
  
  <pre><code>&lt;layout&gt;
  
      &lt;data&gt;
          &lt;variable
              name="textviewt"
              type="String"/&gt;
          &lt;variable
              name="edittexth"
              type="String"/&gt;
      &lt;/data&gt;
  
      &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="center"
          android:orientation="vertical"
          android:showDividers="middle"&gt;
  
          &lt;androidx.appcompat.widget.AppCompatTextView
              android:id="@+id/textview"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@{textviewt}"
              android:textColor="@color/c1"
              android:textSize="12sp"/&gt;
  
          &lt;FrameLayout
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:paddingEnd="26dp"&gt;
  
              &lt;androidx.appcompat.widget.AppCompatEditText
                  android:id="@+id/edittext"
                  android:layout_width="200dp"
                  android:layout_height="wrap_content"
                  android:layout_gravity="center|start"
                  android:layout_marginStart="26dp"
                  android:background="@drawable/activity_login_background"
                  android:hint="@{edittexth}"
                  android:padding="6dp"
                  android:textAlignment="center"
                  android:textColor="@color/c2"
                  android:textColorHint="@color/grey"
                  android:textSize="14sp"/&gt;
  
              &lt;androidx.appcompat.widget.AppCompatImageView
                  android:layout_width="36dp"
                  android:layout_height="36dp"
                  android:layout_gravity="start"
                  android:adjustViewBounds="true"
                  android:src="@drawable/activity_login_edittext_drawable" /&gt;
  
          &lt;/FrameLayout&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/layout&gt;
  </code></pre>