0

Estoy usando los recursos de MaterialDrawer - Mikepenz

Pero no logro encontrar un atributo que me permita hacer invisible ciertos items del NavigationDrawer.

MainActivity.java

private void createNavigationDrawer(Bundle savedInstanceState){
    //Handle Toolbar
    setSupportActionBar(toolbar);

    //Create Header Drawer
    accountHeader = new AccountHeaderBuilder()
            .withActivity(this)
            .withTranslucentStatusBar(true)
            //.withHeaderBackground(R.drawable.header)
            .withSavedInstance(savedInstanceState)
            .build();

    //Create Drawer Layout
    drawer = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .withHasStableIds(true)
            .withItemAnimator(new AlphaCrossFadeAnimator())
            .withAccountHeader(accountHeader)
            .addDrawerItems(
                    new PrimaryDrawerItem().withName("Item 1").withIdentifier(1).withSelectable(true).withEnabled(true),

                    new SectionDrawerItem().withName("Group Item").withEnabled(true),
                    new ExpandableBadgeDrawerItem().withName("Item 2").withIdentifier(2).withSelectable(true).withEnabled(true).withSubItems(
                            new SecondaryDrawerItem().withName("Item 2.1").withIdentifier(21).withSelectable(true).withLevel(2),
                            new SecondaryDrawerItem().withName("Item 2.2").withIdentifier(21).withSelectable(true).withLevel(2)
                    )
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    /*switch ((int) drawerItem.getIdentifier()){
                        case 1:
                            break;
                        case 2:
                            break;
                        case 3:
                            break;
                        case 4:
                            break;
                        case 5:
                            break;
                        case 6:
                            break;
                    }*/
                    return false;
                }
            })
            .withSavedInstance(savedInstanceState)
            .withShowDrawerOnFirstLaunch(false)
            .withShowDrawerUntilDraggedOpened(false)
            .build();
}

1 respuesta 1

0

Hola esa libreria tiene el metodo removeItem si tenes guardado el Drawer solo deberias hacer esto:

mDrawer.removeItem(i);

Pasale como parametro el identificador del item que queres quitar. Tambien podes volverlo a agregar si lo necesitas con el addItem

2
  • Gracias!!!!!!!!!!!! Una pregunta que pasaria en el caso de los ItemsExpandibles? si lo elimino se eliminan todos sus hijos?
    – Brynner
    el 18 oct. 2018 a las 4:08
  • Eso nunca lo probe, pero imagino que si, deberian eliminarse tambien los subitems del item eliminado el 18 oct. 2018 a las 17:26

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.