1
我正在爲我的web服務開發一個android應用程序。開始新的活動onClick
我添加了一個寄存器的TextView的主要活動,並增加了對onClickListener驗證碼:
mRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(LoginActivity.this, RegisterActivity.class));
}
});
當點擊寄存器TextView的,在logcat中返回此錯誤:
01-01 01:36:29.443: E/AndroidRuntime(21558): FATAL EXCEPTION: main
01-01 01:36:29.443: E/AndroidRuntime(21558): java.lang.RuntimeException: Unable to start activity ComponentInfo{us.picbox/us.picbox.RegisterActivity}: java.lang.NullPointerException
01-01 01:36:29.443: E/AndroidRuntime(21558): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1830)
01-01 01:36:29.443: E/AndroidRuntime(21558): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851)
01-01 01:36:29.443: E/AndroidRuntime(21558): at android.app.ActivityThread.access$1500(ActivityThread.java:132)
01-01 01:36:29.443: E/AndroidRuntime(21558): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
01-01 01:36:29.443: E/AndroidRuntime(21558): at android.os.Handler.dispatchMessage(Handler.java:99)
01-01 01:36:29.443: E/AndroidRuntime(21558): at android.os.Looper.loop(Looper.java:150)
01-01 01:36:29.443: E/AndroidRuntime(21558): at android.app.ActivityThread.main(ActivityThread.java:4293)
01-01 01:36:29.443: E/AndroidRuntime(21558): at java.lang.reflect.Method.invokeNative(Native Method)
01-01 01:36:29.443: E/AndroidRuntime(21558): at java.lang.reflect.Method.invoke(Method.java:507)
01-01 01:36:29.443: E/AndroidRuntime(21558): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-01 01:36:29.443: E/AndroidRuntime(21558): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-01 01:36:29.443: E/AndroidRuntime(21558): at dalvik.system.NativeStart.main(Native Method)
01-01 01:36:29.443: E/AndroidRuntime(21558): Caused by: java.lang.NullPointerException
01-01 01:36:29.443: E/AndroidRuntime(21558): at us.picbox.RegisterActivity.onCreate(RegisterActivity.java:85)
01-01 01:36:29.443: E/AndroidRuntime(21558): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
01-01 01:36:29.443: E/AndroidRuntime(21558): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1794)
01-01 01:36:29.443: E/AndroidRuntime(21558): ... 11 more
任何人都可以解釋一下這個問題嗎?
'引起:java.lang.NullPointerException在us.picbox.RegisterActivity.onCreate(RegisterActivity.java:85)'問題從RegisterActivity的第85行開始。發佈RegisterActivity的'onCreate()'方法並指明哪一行是85. – Sam
你是否在manifest中聲明瞭RegisterActivity? –
聲明清單中的活動..! –