Reputation: 336
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!
EDIT: 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.
Upvotes: 1
Views: 2540
Reputation: 1889
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.
Then, in the Adapter's getChildView
method, if you cannot find any child for the specified parent, return a custom view containing your message.
Upvotes: 7
Reputation: 1729
correct me if i am wrong but you can use method setEmpty() to inform a list to be empty. Assuming you have a custom expandable list view in xml with id of android:list and another text view with id of android:empty. In code, you just need to have list.setEmpty(empty_text_view);
Upvotes: 0