title: Android data-binding not working when using inflate() of binding class
body: <p>I'm new to data binding. I have a layout file as below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;layout xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;data&gt;
          &lt;variable name="userProfile" type="com.demo.entity.UserProfile"/&gt;
      &lt;/data&gt;
  
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:padding="16dp"&gt;
          &lt;TextView
              android:id="@+id/username_tv"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentTop="true"
              android:textSize="20sp"
              android:textStyle="bold"
              android:text="@{userProfile.username}" /&gt;
      &lt;/RelativeLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <p>I'm trying to use data binding in android as per the documentation's second method given <a href="https://developer.android.com/topic/libraries/data-binding/index.html#binding_data" rel="nofollow noreferrer">here</a>. I'm not using the first method because I'm inflating the concerned layout into a frame layout which is part of a DrawerLayout in an abstract class so that same navigation drawer can be used across activities [I intend to avoid the complications nested fragments lead to].</p>
  
  <p>Hence my code looks like this:</p>
  
  <pre><code>@Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      inflateActivityViewInFrame(R.layout.activity_profile, R.string.action_profile);
      initialiseData();
  }
  
  private void initialiseData() {
      ActivityProfileBinding binding = ActivityProfileBinding.inflate(getLayoutInflater());
      UserProfile userProfile = new UserProfile("Croaking Tiger Riding Dragon", 8, 16, 32);
      binding.setUserProfile(userProfile);
  }
  </code></pre>
  
  <p>The inflateActivityViewInFrame() method in the parent class does only this:</p>
  
  <pre><code>protected void inflateActivityViewInFrame(int layoutId, int titleStringId) {
      LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View view = inflater.inflate(layoutId, mFrameLayout, false);
      mFrameLayout.addView(view);
  
      setupActionBarAndDrawerToggle(titleStringId);
  }
  </code></pre>
  
  <p>The code compiles fine and there are no log messages either in runtime.
  The entity class is (followed by public getters of all the properties)</p>
  
  <pre><code>public class UserProfile {
      private final String username;
      private final int numContributions;
      private final int numBookmarks;
      private final int numLikes;
  
      public UserProfile(String username, int numContributions, int numLikes, int numBookmarks) {
          this.username = username;
          this.numContributions = numContributions;
          this.numBookmarks = numBookmarks;
          this.numLikes = numLikes;
      }
  </code></pre>
  
  <p>Any thoughts why this isn't working?</p>