You are here
Home > Android > Open Navigation Drawer Programmatically in Android

Open Navigation Drawer Programmatically in Android

Hello Friends, Today I am going to share a code to Open Navigation Drawer Programmatically in Android. And to do so you just need DrawerLayout’s reference and then you can call openDrawer(int) function on it to open drawer. You can also close Drawer programmatically using closeDrawer(int) function but you don’t have to close Drawer because it automatically get closed when you click outside drawer. openDrawer(int) function is useful when you have a custom toolbar and you want to open drawer on a click of an icon in toolbar.

So, Here is code

MainActivity.java

activity_main.xml

app_bar_main.xml

content_main.xml

nav_header_main.xml

 

Video

Download Android Studio Project

 

Thanks for stopping by
Please do share if you like it

Rajesh Kumar Sahanee
I am a passionate Java Developer and I like Computer Programming. I love to do some interesting experiments and listening music in my free time.
https://www.zatackcoder.com

Comments

zatackcoder
Top