如何创建2级或3级可扩展ListView?

时间:2011-04-15 17:37:59

标签: android

我打算创建一个可扩展的Listview,它有两个以上的级别。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

如果您使用自定义ExpandableListView,则可以获得n级BaseExpandableListAdapter

在此扩展适配器中,您将覆盖

public View getGroupView(int groupPosition, boolean isExpanded, 
    View convertView, ViewGroup parent)

方法,将一个ExpandableListView实例分配给convertView,并将其返回。

如果你已经覆盖了适配器中的所有必要方法,那么这应该可行。

In this thread您可以使用ExpandableListView找到BaseExpandableListAdapter的工作样本。如果您修改其getGroupView方法以返回其他ExpandableListView实例,则您将拥有多级列表视图。