I have a navigation bar without any actionbar (I don't want an actionbar). I'm trying to make it so that I have a button that can open the navigation drawer.
I know there's a method called openDrawer for the DrawerLayout http://developer.android.com/reference/android/support/v4/widget/DrawerLayout.html#openDrawer(android.view.View)
I didn't know how to use it, but i have tried making a button when click, runs this method:
DrawerLayout mDrawerLayout = (DrawerLayout) getView().findViewById(R.id.drawer_layout);
mDrawerLayout.openDrawer(mDrawerLayout);
When i click it on it, it gives me a Java NullPointerException. Anybody has any idea?
EDIT: This code is inside a fragment, and I'm trying to refer those drawer layout outside the fragment. I used debugger, and it is showing that mDrawlerLayout is NULL.
Any advice?
Thanks!
mDrawerLayout.openDrawer(Gravity.LEFT);
inopenDrawer
method to make it work. (I am using navigation drawer without both fragments & action bar) Otherwise, it just hangs the app. – Chondriosome