title: Android: setOnKeyListener on EditText
body: <p>I have a EditText on my View and I would like to set a onKeyListener.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>final EditText edittext = (EditText) findViewById(R.id.editText1);
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      edittext.setOnKeyListener(new EditText.OnKeyListener() {
      public boolean onKey(View v, int keyCode, KeyEvent event) {
  
              return false;
          }
      });   
  }
  </code></pre>
  
  <p>The problem is that i have problems with this, here is a error part of the logcat:</p>
  
  <pre><code>W/dalvikvm(3703): threadid=1: thread exiting with uncaught exception (group=0x40015560)
  E/AndroidRuntime(3703): FATAL EXCEPTION: main
  E/AndroidRuntime(3703): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{milos.mdpi/milos.mdpi.MDPIActivity}: java.lang.NullPointerException
  E/AndroidRuntime(3703):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
  E/AndroidRuntime(3703):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
  E/AndroidRuntime(3703):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  E/AndroidRuntime(3703):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  E/AndroidRuntime(3703):     at android.os.Handler.dispatchMessage(Handler.java:99)
  E/AndroidRuntime(3703):     at android.os.Looper.loop(Looper.java:123)
  E/AndroidRuntime(3703):     at android.app.ActivityThread.main(ActivityThread.java:3683)
  E/AndroidRuntime(3703):     at java.lang.reflect.Method.invokeNative(Native Method)
  E/AndroidRuntime(3703):     at java.lang.reflect.Method.invoke(Method.java:507)
  E/AndroidRuntime(3703):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  E/AndroidRuntime(3703):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  E/AndroidRuntime(3703):     at dalvik.system.NativeStart.main(Native Method)
  E/AndroidRuntime(3703): Caused by: java.lang.NullPointerException
  E/AndroidRuntime(3703):     at android.app.Activity.findViewById(Activity.java:1647)
  E/AndroidRuntime(3703):     at milos.mdpi.MDPIActivity.&lt;init&gt;(MDPIActivity.java:22)
  E/AndroidRuntime(3703):     at java.lang.Class.newInstanceImpl(Native Method)
  E/AndroidRuntime(3703):     at java.lang.Class.newInstance(Class.java:1409)
  E/AndroidRuntime(3703):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
  E/AndroidRuntime(3703):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
  E/AndroidRuntime(3703):     ... 11 more
  </code></pre>