Question

I am trying to implement navigation drawer in my android app. I used This tutorial : http://manishkpr.webheavens.com/android-navigation-drawer-example-using-fragments/ which shows to implement the navigation drawer with the use of fragments. But my app force closes as I am trying to run it on API 10 (Gingerbread)

But it works only on 3.0 Honeycomb+. How do I make it work on 2.3 Gingerbread+ and in fullscreen mode. Please I need help!

Thanks in advance!

StackTrace

01-09 16:01:07.971  16470-16470/com.Chinmay.navigationdrawer E/AndroidRuntime﹕ FATAL     EXCEPTION: main
    java.lang.NoSuchMethodError: com.Chinmay.navigationdrawer.MainActivity.getActionBar
    at com.Chinmay.navigationdrawer.MainActivity.onCreate(MainActivity.java:25)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3687)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
    at dalvik.system.NativeStart.main(Native Method)
Was it helpful?

Solution

Navigation Drawer is not available for Android 2.3 Gingerbread. You must use AppCompat support library to use Navigation Drawer on older versions. There is a good tutorial here

OTHER TIPS

Pre honeycomb there is no ActionBar available. That's why your App crashes at the call getActionBar().

You have to use the SherlockActionbar library or the ActionbarCompat from the support library. If you use one of these change the call to getSupportActionBar().

You're calling getActionBar() which has been added in API level 11. You'll need to extend SherlockActivity or use the compatibility library and then call getSupportActionBar() in order to fix the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top