title: Android data binding two-way not working
body: <p>I am trying to use two-way data binding for editing user data. I am able to show the POJO contents in the view but the changes made by user are not able to capture back with POJO.</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      ActivityMainBinding binding;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          binding  = DataBindingUtil.setContentView(this, R.layout.activity_main);
  
          User user = new User();
          user.setFirstName("first a");
          user.setLastName("last b");
  
          binding.setUser(user);
      }
      public void Click(View v){
  
          //ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());
          User user = binding.getUser();
  
          Toast.makeText(this,user.getFirstName(),Toast.LENGTH_LONG).show();
      }
  }
  </code></pre>
  
  <p>I have tried using a global variable for <code>user</code>, <code>binding</code> too. But when I click the button, it always shows the "first a". The definition for User.java is: </p>
  
  <pre><code>public class User extends BaseObservable{
      private String firstName;
      private String lastName;
  
      @Bindable
      public String getFirstName(){ return firstName;}
      public void setFirstName(String first) {
          firstName = first;
          notifyPropertyChanged(com.example.ks.myapplication.BR.firstName);
      }
      @Bindable
      public String getLastName(){ return lastName;}
      public void setLastName(String last) {
          lastName = last;
          notifyPropertyChanged(com.example.ks.myapplication.BR.lastName);
      }
  }
  </code></pre>
  
  <p>and the XML: Here, I am trying to display the changes immediately in text views and on button click also.</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="user" type="com.example.ks.myapplication.User"/&gt;
      &lt;/data&gt;
      &lt;LinearLayout
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;EditText
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/editText2"
              android:text="@{user.firstName}" /&gt;
  
          &lt;EditText
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:id="@+id/editText"
              android:text="@{user.lastName}" /&gt;
  
          &lt;Button
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="New Button"
              android:id="@+id/button"
              android:layout_gravity="center_horizontal"
              android:onClick="Click" /&gt;
  
          &lt;TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@{user.firstName}"/&gt;
  
          &lt;TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@{user.lastName}"/&gt;
      &lt;/LinearLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <p>Is there anything I am missing?</p>