Materialdrawer: 2 Expandable Items inside each other withOnlyOneExpandedItem

Created on 7 Jan 2017  ·  4Comments  ·  Source: mikepenz/MaterialDrawer

result.getAdapter().withOnlyOneExpandedItem(true);
Is not working with the 2nd level of expandable items, It is working for all expandable items including the 1st level of them, So on expanding the 2nd inside-ed item it collapse the 1st level one

even using this method
if(previousExpandableItemPosition != position) { result.getAdapter().collapse(previousExpandableItemPosition); previousExpandableItemPosition = position; }
bugged on the 3rd dirffrerent item of 2nd position

for more explanation
Expandable item 1 --> "1st level"
Expandable item 2 -------> "2nd level"
Normal item 3 -----------------> "3rd level"

the method of withOnlyOneExpandedItem needs to be customized with .withLevel()

question

Most helpful comment

@DasserBasyouni the withOnlyOneExpandedItem was not created to work for deeper hierarchies.
If you want to collapse others but allow the single hierachy you will have to handle this manually.

All 4 comments

@DasserBasyouni the withOnlyOneExpandedItem was not created to work for deeper hierarchies.
If you want to collapse others but allow the single hierachy you will have to handle this manually.

sorry for the stupid question but will you tell me how, I have tried and searched so much

@DasserBasyouni the MaterialDrawer's internals depend on the FastAdapter, so everything which is true for the FastAdapter is true for the MaterialDrawer

https://github.com/mikepenz/FastAdapter

You can get the FastAdapter via Drawer.getAdapter(). In general you will have to listen for the click event. and collapse items which are not inside the current hierarchy.
So you can get the current expanded elements via the FastAdapter.
And the FastAdapter also has the methods which allow you to collapse an item.

The general complexity here is that nested collapsable hierarchies are not too easy to handle as many aspects have to be considered.

thank you so much, appreciate your reply

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ahmed-Emad picture Ahmed-Emad  ·  4Comments

GutoMartins019 picture GutoMartins019  ·  4Comments

meness picture meness  ·  3Comments

AlexMercier picture AlexMercier  ·  3Comments

sonh picture sonh  ·  3Comments