04-03 10:19:34.572 2189-2189/com.techexpert4u.duaaadhkaar E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.techexpert4u.duaaadhkaar, PID: 2189
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.techexpert4u.duaaadhkaar/com.techexpert4u.duaaadhkaar.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.techexpert4u.duaaadhkaar.MainActivity.onPostCreate(MainActivity.java:936)
at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1150)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2178)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
我需要幫助這個請幫助我。引起︰java.lang.NullPointerException MainActivity.onPostCreate
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred.
mDrawerToggle.syncState();
}
哪裏在代碼中我找不到它。 – Solaiman 2015-04-03 22:52:56
@Solaiman如果你關注你的堆棧跟蹤,你會發現它在936行。你如何初始化你的'mDrawerToggle'對象? – joao2fast4u 2015-04-03 22:59:17
我做到了,我仍然有問題。我在 – Solaiman 2015-04-03 23:59:22