I want to call some methods when Navigation Drawer is opened & closed. How can I listen to it (like button\'s onclick listener) ?
I know we can check (mDra
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) {
super.onDrawerClosed(view);
// Do whatever you want here
}
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
// Do whatever you want here
}
};
mDrawerLayout.addDrawerListener(mDrawerToggle);
copied from http://developer.android.com/reference/android/support/v4/widget/DrawerLayout.DrawerListener.html
UPDATE
setDrawerListener
method was deprecated in API level 24.1.0. so use addDrawerListener()