title: Android EditText onClick Listener defined in Layout fails with obscure Exception
body: <p>I want to define an onClick Listener for an EditText in the Layout-XML of may activity, but it always fails with an obscure Exception. </p>
  
  <p>The Layout is injected with <code>setContentView()</code>in the <code>onCreate</code>-Method of my activity. I am <strong>not</strong> using a Fragment here and I am well aware that the XML defined <code>onClick</code> Listener do not work for fragments. </p>
  
  <p><strong>For testing purposes I added the same handler method to an ImageView that is located next to the EditText. There the handler works, on the EditText it fails. So this is something special of the EditText and not a general Problem of a mislocated handler method.</strong></p>
  
  <p>This is the relevant part of my layout file:
  </p>
  
  <pre><code>&lt;ImageView
       android:layout_gravity="center_horizontal|top"
       android:layout_rowSpan="3"
       android:src="@drawable/ic_action_event"
       android:onClick="onCreationClicked"
       /&gt;
  
  &lt;EditText
       android:id="@+id/creation_edit"
       android:focusable="false"
       android:clickable="true"
       android:layout_gravity="fill_horizontal"
       android:hint="@string/enter_creation"
       android:onClick="onCreationClicked"
       style="@style/PickerEditText"
       /&gt;
  </code></pre>
  
  <p>When I click on the ImageView the associated method is executed and a DialogFragment is started. When I click on the EditText I get the following Exception:</p>
  
  <pre><code>    java.lang.IllegalStateException: Could not find a method onCreationClicked(View) in the activity class android.support.v7.internal.widget.TintContextWrapper for onClick handler on view class android.support.v7.widget.AppCompatEditText with id 'creation_edit'
              at android.view.View$1.onClick(View.java:3994)
              at android.view.View.performClick(View.java:4756)
              at android.view.View$PerformClick.run(View.java:19749)
              at android.os.Handler.handleCallback(Handler.java:739)
              at android.os.Handler.dispatchMessage(Handler.java:95)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5221)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       Caused by: java.lang.NoSuchMethodException: onCreationClicked [class android.view.View]
              at java.lang.Class.getMethod(Class.java:664)
              at java.lang.Class.getMethod(Class.java:643)
              at android.view.View$1.onClick(View.java:3987)
              at android.view.View.performClick(View.java:4756)
              at android.view.View$PerformClick.run(View.java:19749)
              at android.os.Handler.handleCallback(Handler.java:739)
              at android.os.Handler.dispatchMessage(Handler.java:95)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5221)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
  </code></pre>
  
  <p>I am currently testing on a Samsung S4 (Android 5.0.1) API 21 and AppCompat Library in Version v7 22.1.0</p>
  
  <p>Adding the <code>onClick</code> Listener programmatically in the <code>onCreate</code> method would be a solution, but I wanted to avoid this, since it results in a single <code>onClick</code> method with a big switch statement and the XML-based onClick-Handler result in a more readable and explicit code which I prefer. </p>
  
  <p><strong>Did additional research:</strong></p>
  
  <p>Now I can reproduce the error behaviour and the correct behavior (see below). It seems this is a bug (or a feature) introduced with appcompat-v7 22.1.0 &amp; 22.1.1.</p>
  
  <p>I created a new fresh project with Android Studio with Blank Activity. minSdk 17, targetSdk 21. Added the <code>EditText</code> to the blank <code>Activity</code> as shown below and added the handler method to the <code>Activity</code> like this:</p>
  
  <pre><code>public void onCreationClicked(View view) {
      Toast.makeText(this,"Event Handled",Toast.LENGTH_LONG).show();
  }
  </code></pre>
  
  <p>Started the App touched the EditText --> Crash</p>
  
  <p>Changed my build.gradle from:</p>
  
  <pre><code>    compile 'com.android.support:appcompat-v7:22.1.1'
  </code></pre>
  
  <p>to</p>
  
  <pre><code>    compile 'com.android.support:appcompat-v7:22.0.0'
  </code></pre>
  
  <p>and the <code>Toast</code> is shown. </p>
  
  <p>Any ideas?</p>