问题描述
我正在开发一个具有ExpandableListActivity的应用程序.当一个小组没有孩子时,我希望它显示一条消息,就好像它是一个孩子一样,通知该列表为空,如图所示:
I am developing an app which has an ExpandableListActivity. When a group has no children, I would like it to show a message, as if it was a child, informing that the list is empty, as shown in the picture:
是否有任何(合理简单)的方法或类似的方法?
Is there any (reasonably simple) way to do this, or something similar?
很抱歉,是否曾经有人问过我-我以为一定是这样,但是我什么也没找到.谢谢!
I am sorry if this has been asked before - I kind of assume it must have been, but I haven't been able to find anything. Thank you!
为澄清起见,我要寻找的不是完整ExpandableListView(可以通过setEmptyView设置)的空视图,而是没有孩子的父组.
To clarify, what I'm looking for is not an empty view for the complete ExpandableListView (which can be set with setEmptyView), but for parent groups with no children.
推荐答案
我对这个特定类的经验不是很好,但是我建议尝试覆盖Adapter的getChildrenCount
方法以在没有该类的情况下返回1任何子记录.
My experience with this particular class isn't that great, but I would suggest trying to override the Adapter's getChildrenCount
method to return 1 when there aren't any child records.
然后,在适配器的getChildView
方法中,如果找不到指定的父级的任何子级,则返回包含消息的自定义视图.
Then, in the Adapter's getChildView
method, if you cannot find any child for the specified parent, return a custom view containing your message.
这篇关于ExpandableListView-空组消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!