-1

I want to change the items on my navigation drawer based on the user that has logged in and if they have premium account or not.

I know how to make items visible and invisible, but I was wondering if I can put a function somewhere that when ever it's toggled it would set the visibility of them items and also change the header based on the user profile.

thank you all in advance.

2 Answers2

0

Add a DrawerListener to your DrawerLayout

mDrawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {
            @Override
            public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {

            }

            @Override
            public void onDrawerOpened(@NonNull View drawerView) {

            }

            @Override
            public void onDrawerClosed(@NonNull View drawerView) {

            }

            @Override
            public void onDrawerStateChanged(int newState) {

            }
        });
feridok
  • 648
  • 7
  • 26
0

I suggest you add a DrawerListener to your DrawerLayout

drawerLayout.addDrawerListener(new DrawerToggle());

DrawerToggle is an extension of android.support.v4.widget.SimpleDrawerListener in which you've overidden onClick() and onDrawerSlide()

 @Override
 public void onClick(View v) {
     mDrawerLayout.openDrawer(GravityCompat.START);
 }



@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
    super.onDrawerSlide(drawerView, slideOffset);
}

You can use these methods to catch drawer toggle event

matdev
  • 4,115
  • 6
  • 35
  • 56