The title explains it all. All what I want to do is to know if the navigation drawer is open or not. I searched a lot on the net and found the method isDrawerOpen(int drawerGravity)
but couldn't find a satisfactory answer which explains how to use it in a method. I would appreciate if anyone explains it to me.
Thanks in advance!
If you would like to determine if drawer is open or closed, you can do the following: import { useDrawerStatus } from '@react-navigation/drawer'; // ...
The navigation drawer slides in from the left and contains the navigation destinations for the app. The user can view the navigation drawer when the user swipes a finger from the left edge of the activity. They can also find it from the home activity by tapping the app icon in the action bar.
Use closeDrawer() method to close the drawer and start your other activity on the listener of drawer.
Assuming you have defined a drawerlayout in xml:
DrawerLayout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); ... if(mDrawerLayout.isDrawerOpen(GravityCompat.START)) { //drawer is open }
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle( this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description */ R.string.drawer_close /* "close drawer" description */ ) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); getActionBar().setTitle(mTitle); } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); getActionBar().setTitle(mDrawerTitle); } }; // Set the drawer toggle as the DrawerListener mDrawerLayout.setDrawerListener(mDrawerToggle);
That listener use:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With