mikepenz / MaterialDrawer

The flexible, easy to use, all in one drawer library for your Android project. Now brand new with material 2 design.
https://mikepenz.dev
Apache License 2.0
11.67k stars 2.05k forks source link

Multiple drawer items remain selected #2768

Closed thimovandenberg closed 2 years ago

thimovandenberg commented 2 years ago

About this issue

Hi, I have a small issue with multiple drawer items remaining selected when setSelection() is used. I have tried to setting setMultiselect(false), but this causes the problem to persist and items are not selected anymore when clicked on them.

image

I have created a small project to show the behavior here By pressing the button the selection is changed, but the previously selected item remains selected. Enabling mSlider.setMultiSelect(false) does not resolve this, but causes the items to not be selected when clicked.

I also saw a similar issue here, but this was not resolved I believe.

Details

thimovandenberg commented 2 years ago

Oh actually I just noticed using setSelectionAtPosition does work

mikepenz commented 2 years ago

Thank you for the report @thimovandenberg will need to have a look.

Is there a reason for the need to calling multiSelect=false?

thimovandenberg commented 2 years ago

I used multiSelect = false because it was mentioned as a potential fix in the other thread. I was migrating from an older version of the library where setSelection() caused the other items to be unselected. I have now changed this to setSelectionAtPosition() and it works as intended. Thanks for looking at it :)