0

Доброго времени суток. Использую библиотеку MaterialDrawer. Требуется создать вложенный список в одном из пунктов меню, при нажатии на который этот список будет открываться. Может кто делал такое, подскажите пожалуйста. Спасибо. Инициализация:

final PrimaryDrawerItem item23 = new PrimaryDrawerItem().withIdentifier(23).withName(R.string.change_night_mode).withIcon(R.drawable.button_night_mode).withSelectable(false);
PrimaryDrawerItem item22 = new PrimaryDrawerItem().withIdentifier(22).withName(R.string.about_name).withSelectable(false).withIcon(R.drawable.about);

result = new DrawerBuilder()
        .withActivity(this)
        .withToolbar(toolbar)
        .withHeader(R.layout.drawer_header)
        .withTranslucentStatusBar(true)
        .withActionBarDrawerToggleAnimated(true)
        .addDrawerItems(
                item23,
                new DividerDrawerItem(),
                item22
        )
        .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
            @Override
            public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                switch((int) drawerItem.getIdentifier()){
                    case 22: 
                        break;
                    case 23: 
                        break;
                }
                return true;
            }
        })
        .build();

1 ответ 1

2

В сэмплах Майка есть пример с айтемом, в котором раскрываются еще айтемы:

Коротко:

result = new DrawerBuilder()
            .withActivity(this)
            .withToolbar(toolbar)
            .addDrawerItems( new ExpandableDrawerItem().withName("Collapsable").withIcon(GoogleMaterial.Icon.gmd_collection_case_play).withIdentifier(19).withSelectable(false).withSubItems(
                            new SecondaryDrawerItem().withName("CollapsableItem").withLevel(2).withIcon(GoogleMaterial.Icon.gmd_8tracks).withIdentifier(2000)
                            new SecondaryDrawerItem().withName("CollapsableItem 2").withLevel(2).withIcon(GoogleMaterial.Icon.gmd_8tracks).withIdentifier(2001))
            .build();
1
  • Большое Вам спасибо! Я бы там и не нашел.
    – Pollux
    20 авг 2016 в 14:27

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.