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()
@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
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.