Databinding: Bind single method from listener with multiple methods
<p>Yigit Boyar and George Mount members of the Android UI Toolkit team gave a <a href="https://realm.io/news/data-binding-android-boyar-mount/" rel="noreferrer">talk on databinding</a>. In the video at 13:41 George Mount says this</p>

<blockquote>
  <p>You can also do some of the weird listeners, like onTextChanged.
  TextWatcher has three methods on it, but everybody only cares about
  onTextChanged, right? <strong>You can actually access just one of them if you
  want, or all of them.</strong>"</p>

<pre><code>&lt;Button android:onTextChanged="@{handlers.textChanged}" …/&gt;
</code></pre>
</blockquote>

<p>He seemed to be saying that instead of using the usual <a href="https://developer.android.com/reference/android/widget/TextView.html#addTextChangedListener(android.text.TextWatcher)" rel="noreferrer">addTextChangedListener</a> method that looks something like this</p>

<pre><code>editText.addTextChangedListener(new TextWatcher() {
    @Override
    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

    @Override
    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        //Do something
    }

    @Override
    public void afterTextChanged(Editable editable) {}
});
</code></pre>

<p>we could simply do this</p>

<pre><code>&lt;EditText 
    android:onTextChanged="@{handlers::onTextChanged}"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/&gt;
</code></pre>

<p>Handlers class</p>

<pre><code>public class Handlers{
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        //Do something
    }
}
</code></pre>

<p>The code works in this instance, but it doesn't seem to work in other cases where the listener has multiple methods like ViewPager's <a href="https://developer.android.com/reference/android/support/v4/view/ViewPager.html#addOnPageChangeListener(android.support.v4.view.ViewPager.OnPageChangeListener)" rel="noreferrer">addOnPageChangeListener</a> method. For example this doesn't work</p>

<pre><code>&lt;android.support.v4.view.ViewPager
    android:OnPageSelected="@{handlers::onPageSelected}"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/&gt;
</code></pre>

<p>and the Handlers class</p>

<pre><code>public class Handlers{
    public void onPageSelected(int position) {
        //Do something
    }
}
</code></pre>

<p>The project spits out this error when trying to build</p>

<pre><code>Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
&gt; java.lang.RuntimeException: Found data binding errors.
****/ data binding error ****msg:Could not resolve handlers::onPageSelected as a listener.

****\ data binding error ****
</code></pre>

<p>I'm a bit confused now because it turns out that EditText actually has an inherited <a href="https://developer.android.com/reference/android/widget/TextView.html#onTextChanged(java.lang.CharSequence,%20int,%20int,%20int)" rel="noreferrer">onTextChanged</a> method which the databinding library can also bind <code>android:onTextChanged="@{handlers::onTextChanged}"</code> to.</p>

<p>So my question is that is it actually possible to bind to a single listener method and I'm missing something, or did George Mount make a mistake in his talk?</p>