一次仅显示可扩展列表的一个子项
是否可以一次仅展开 ExpandableListView
的一个子项,从而打开第二个子项将关闭之前打开的子项?
Is it possible to only expand one child of an ExpandableListView
at a time, thus opening a second child would close the previously opened child?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
只是为了确认 bos 在代码中的答案:
Just to confirm bos's answer in code:
我不知道有任何自动方法可以实现此目的,但您可以实现
ExpandableListView.OnGroupClickListener
,在其中为除被单击的列表组之外的所有列表组运行collapseGroup()
。这将做你想做的事。I'm not aware of any automatic methods for this, but you can implement
ExpandableListView.OnGroupClickListener
, in where you runcollapseGroup()
for all list groups except the one being clicked. This will do what you want.FastAdapter 中的
withOnlyOneExpandedItem()
您还可以简单地使用位于 FastAdapter 外部库中的 作者:mikepenz
例如,我在抽屉中使用它
Also you can simple use the
withOnlyOneExpandedItem()
which is in FastAdapterthat is in FastAdapter External Library by mikepenz
For example as I am using it in my Drawer
您可以将其用于各种条件,就像您在扩展列表中所做的那样 -
you can use this for various conditions as you want to do in expansion of list -