title: Using DataBinding library for binding events
body: <p>I'm trying to bind events with views in xml using <strong>DataBinding Library</strong> shipped with Android M. I'm following examples from <a href="https://developer.android.com/tools/data-binding/guide.html">Android Developers</a> and implementing step-by-step. for the view's attributes like visibility,text its working fine but if I try to bind with onclick, it doesn't work as expected. Here's the sample code that I've tried so far: </p>
  
  <pre><code> &lt;data&gt;
      &lt;import type="android.view.View"/&gt;
      &lt;variable name="user" type="com.example.databinding.User"/&gt;
      &lt;variable name="handlers" type="com.example.databinding.MyHandlers"/&gt;
  &lt;/data&gt;
  
   &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@{user.firstName}"
      android:visibility="@{user.isFriend ? View.VISIBLE : View.GONE}" /&gt;
   &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Click Me"
      android:id="@+id/button"
      android:layout_gravity="left"
      android:onClick="@{handlers.onClickFriend}"/&gt;
  </code></pre>
  
  <p>MainActivity :</p>
  
  <pre><code>  public class MainActivity extends AppCompatActivity {
  
    User user;
  
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      ActivityMainBinding binding = 
      DataBindingUtil.setContentView(this,R.layout.activity_main);
      user = new User("Pankaj","Kumar",true,true);
      binding.setUser(user);
     }
   }
  </code></pre>
  
  <p>MyHandlers:</p>
  
  <pre><code>public class MyHandlers {
  public void onClickFriend(View view){
      Log.i(MyHandlers.class.getSimpleName(),"Now Friend");
  }
  
  public void onClickEnemy(View view){
      Log.i(MyHandlers.class.getSimpleName(),"Now Enemy");
    }
  }
  </code></pre>
  
  <p>I've written only required code to improve readability. Could someone help me on this.</p>