Android application crashes on key Enter
<p>I'm about to develop an Android 2.2.3, Gingerbread. APILevel 10 application.
I invoke a listener on an EditText for capturing ENTER key press events.
The problem is that when I klick on Enter in my application it accidently stops.
Below is the main code block for it.</p>

<pre><code>//Declare the listener
answertext.setOnEditorActionListener(answerOnKeyDownListener);

//Invoke the event handler
private TextView.OnEditorActionListener answerOnKeyDownListener = new TextView.OnEditorActionListener() {

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
{
    if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)
    {
    answerOnClickListener.onClick(v);
}
    return false;
}
};
</code></pre>

<p>}</p>

<p>And this is what logcat telling me when I press the ENTER</p>

<pre><code>12-30 09:01:52.252: D/AndroidRuntime(522):      Shutting down VM
12-30 09:01:52.252: W/dalvikvm(522): threadid=1:    thread exiting with uncaught exception (group=0x40015560)
12-30 09:01:52.272: E/AndroidRuntime(522):      FATAL EXCEPTION: main
12-30 09:01:52.272: E/AndroidRuntime(522):      java.lang.NullPointerException
12-30 09:01:52.272: E/AndroidRuntime(522):      at mental.arithmetic.MentalArithmeticActivity$5.onEditorAction(MentalArithmeticActivity.java:231)
12-30 09:01:52.272: E/AndroidRuntime(522):      at android.widget.TextView.onEditorAction(TextView.java:3163)
12-30 09:01:52.272: E/AndroidRuntime(522):      at com.android.internal.widget.EditableInputConnection.performEditorAction(EditableInputConnection.java:83)
12-30 09:01:52.272: E/AndroidRuntime(522):      at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:291)
12-30 09:01:52.272: E/AndroidRuntime(522):      at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:75)
12-30 09:01:52.272: E/AndroidRuntime(522):      at android.os.Handler.dispatchMessage(Handler.java:99)
12-30 09:01:52.272: E/AndroidRuntime(522):      at android.os.Looper.loop(Looper.java:123)
12-30 09:01:52.272: E/AndroidRuntime(522):      at android.app.ActivityThread.main(ActivityThread.java:3683)
12-30 09:01:52.272: E/AndroidRuntime(522):      at java.lang.reflect.Method.invokeNative(Native Method)
12-30 09:01:52.272: E/AndroidRuntime(522):      at java.lang.reflect.Method.invoke(Method.java:507)
12-30 09:01:52.272: E/AndroidRuntime(522):      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-30 09:01:52.272: E/AndroidRuntime(522):      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-30 09:01:52.272: E/AndroidRuntime(522):      at dalvik.system.NativeStart.main(Native Method)
12-30 09:02:01.132: I/Process(522):             Sending signal. PID: 522 SIG: 9
</code></pre>
