Events may be bound to handler methods directly, similar to the way
<strong><code>android:onClick</code></strong> can be assigned to a method in the Activity.
Data Binding allows you to write expressions handling events that are dispatched from the views (e.g. onClick).
Event attribute names are governed by the name of the listener method with a few exceptions.
For example, {@link android.view.View.OnLongClickListener} has a method {@link android.view.View.OnLongClickListener#onLongClick onLongClick()},
so the attribute for this event is <code>android:onLongClick</code>.
There are two ways to handle an event.
</p>
<ul>
<li>
<a href="#method_references">Method References</a>: In your expressions, you can reference methods that conform to the signature of the listener method. When an expression evaluates to a method reference, Data Binding wraps the method reference and owner object in a listener, and sets that listener on the target view. If the expression evaluates to null, Data Binding does not create a listener and sets a null listener instead.
</li>
<li>
<a href="#listener_bindings">Listener Bindings</a>: These are lambda expressions that are evaluated when the event happens.
Data Binding always creates a listener, which it sets on the view. When the event is dispatched, the listener evaluates the lambda expression.
</li>
</ul>
<h4 id="method_references">
Method References
</h4>
<p>
Events can be bound to handler methods directly, similar to the way
<strong><code>android:onClick</code></strong> can be assigned to a method in an Activity.
One major advantage compared to the {@code View#onClick} attribute is that the expression
is processed at compile time, so if the method does not exist or its signature is not
correct, you receive a compile time error.</p>
<p>
The major difference between Method References and Listener Bindings is that
the actual listener implementation is created when the data is bound, not
when the event is triggered. If you prefer to evaluate the expression when
the event happens, you should use <a href="#listener_bindings">listener
binding</a>.
</p>
<p>
To assign an event to its handler, use a normal binding expression, with the value