Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only one expanded item : how to ? #2806

Open
9 tasks done
engi opened this issue May 22, 2024 · 1 comment
Open
9 tasks done

Only one expanded item : how to ? #2806

engi opened this issue May 22, 2024 · 1 comment
Assignees

Comments

@engi
Copy link

engi commented May 22, 2024

About this issue

Hi Mike,

Question is in the title : how can I have only one expandable item expanded at one time?
I have two expandable items (ids 2 and 3).

I tried this in onDrawerItemClickListener :

2L -> { //dictionnaries item
    val itemBackup: IDrawerItem<*>? = binding?.slider?.getDrawerItem(3L)
    if ((itemBackup != null) && itemBackup.isExpanded) {
        val positionItemBackup: Int = binding?.slider?.itemAdapter!!.getAdapterPosition(3)
        binding?.slider?.expandableExtension!!.collapse(positionItemBackup, true)
    }
}
3L -> { //backups item
    val itemDico: IDrawerItem<*>? = binding?.slider?.getDrawerItem(2L)
    if ((itemDico != null) && itemDico.isExpanded) {
        val positionItemDico: Int = binding?.slider?.itemAdapter!!.getAdapterPosition(2)
        binding?.slider?.expandableExtension!!.collapse(positionItemDico, true)
    }
}

or this :

binding?.slider?.apply {
    addItems(
        alarmDrawerItem,
        dicoDrawerItem,
        backupDrawerItem,
        settingsDrawerItem
    )
    expandableExtension.isOnlyOneExpandedItem = true
    setSavedInstance(savedInstanceState)
}

but it doesn't work !

Details

  •  Used library version 8.4.5
  •  Used androidX library last version
  •  Used Android Studio last version

Checklist

@mikepenz
Copy link
Owner

You can retrieve the adapter from the MaterialDrawerSlidingView which exposes a expandableExtension API:

adapter.expandableExtension {
    isOnlyOneExpandedItem = true
}

@mikepenz mikepenz self-assigned this May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants