Navigation drawer 2.3 gingerbread

风流意气都作罢 提交于 2019-12-23 02:43:20

问题


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)

回答1:


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




回答2:


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().




回答3:


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.



来源:https://stackoverflow.com/questions/21017516/navigation-drawer-2-3-gingerbread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!