从谷歌ExpandableListView样本样本、ExpandableListView

2023-09-04 05:29:03 作者:百无一用是情深

我只是想在当前谷歌样品 ExpandableListiew

I just tried the current Google sample for ExpandableListiew:

此示例看起来很简单,易于使用,但我想这样做是说的类别之一,没有孩子。我删除了所有的孩子,但问题是,箭头仍显示在这个当前行。

This sample seem very simple and easy to use, but what I would like to do is to say that one of the category has no child. I removed all the children but the problem is that the arrow still appears on this current line.

例如,假设我删除所有的名猫的,箭头依然存在,当我点击它,箭头只是改变。如何删除这个箭头,推出一个活动呢?

For instance, imagine that I remove all "Cat Names", the arrow is still there and when I click on it, the arrow just change. How to remove this arrow and launch an activity instead?

推荐答案

如果你在谈论的是用于折叠/展开列表,然后箭头可以使用setGroupIndicator将其删除()

If you're talking about the arrow that is used to collapse/expand the list then you can remove it by using setGroupIndicator()

在活动中,您可以致电

getExpandableListView().setGroupIndicator(null);

这将删除箭头永久虽然。如果你只想隐藏它,如果该列表是空的,你可以做到这一点通过XML属性,如this

that will remove the arrow permanently though. If you want to only hide it if the list is empty you can do it through xml attributes like this

要启动一个活动时,列表展开/折叠,你可以在你的ListAdapter实现覆盖onGroupExpanded(或折叠),并使用了火了你的活动

To launch an activity when the list is expanded/collapsed you can override onGroupExpanded (or collapsed) in your ListAdapter implementation and used that to fire up your activity

 
精彩推荐