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)
我需要帮助,请帮助我。
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
// Sync the toggle state after onRestoreInstanceState has occurred.
mDrawerToggle.syncState();
}
答案 0 :(得分:0)
鉴于源和堆栈跟踪,显然mDrawerToggle
为null
。
答案 1 :(得分:0)
null mDrawerToggle字段似乎应该在您的initializeDrawer()代码中初始化,但没有证据表明您曾调用该方法。
在onCreate()中调用initializeDrawer,或者在尝试使用mDrawerToggle 之前确保它在任何代码路径中发生。