1

我收到了这个例外:

java.lang.NullPointerException 
at com.callsfreecalls.android.SmsSend$4.onClick(SmsSend.java:179) 
at android.view.View.performClick(View.java:3538) 
at android.view.View$PerformClick.run(View.java:14330) 
at android.os.Handler.handleCallback(Handler.java:608) 
at android.os.Handler.dispatchMessage(Handler.java:92) 
at android.os.Looper.loop(Looper.java:156) 
at android.app.ActivityThread.main(ActivityThread.java:4987) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
at dalvik.system.NativeStart.main(Native Method)

为了代码的和平:

editSmsText = (EditText) findViewById(R.id.editSmsText);
editSmsText.setOnKeyListener(new OnKeyListener() {
    public boolean onKey(View v, int keyCode, KeyEvent event) {
        // If the event is a key-down event on the "enter" button
        if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { // <- this is line 179
            // Perform action on key press
            //adapter.add(new OneComment(false, editSmsText.getText().toString()));
            //editSmsText.setText("");
            return true;
        }
        return false;
    }
});

private EditText editSmsText;

有什么建议吗?将editSmsText推到静态?

4

0 回答 0