Venkatesh Selvam Venkatesh Selvam - 5 months ago 31
Android Question

Can i listen Navigation drawer is open or close (e.g: listener like button onclick)

I want to do call some methods when Navigation Drawer is open & close. How can i listen it (like button onclick listener) ?

I know we can check (

) or (

Thanks in Advance.


Yeah there are four abstract methods that you can use as listeners

public abstract void onDrawerClosed (View drawerView)
public abstract void onDrawerOpened (View drawerView)
public abstract void onDrawerSlide (View drawerView, float slideOffset)
public abstract void onDrawerStateChanged (int newState)

can be used like this

ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
        R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
    public void onDrawerClosed(View view) {
        // Do whatever you want here
    public void onDrawerOpened(View drawerView) {
        // Do whatever you want here

copied from