James
James

Reputation: 14091

How can I create a 2 level or 3 level expandable ListView?

I am planning to create an expandable Listview that has more than 2 levels. How can I do this?

Upvotes: 2

Views: 2929

Answers (1)

rekaszeru
rekaszeru

Reputation: 19220

You can achieve an n-level ExpandableListView, if you use it with your custom BaseExpandableListAdapter.

In this extended adapter, you override the

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

method, assign an ExpandableListView instance to the convertView, and return it.

If you have overriden all the necessary methods in your adapter, this should work.

In this thread you can find a working sample of ExpandableListView using BaseExpandableListAdapter. If you modify its getGroupView method to return an other ExpandableListView instance, you'll have a multilevel listview.

Upvotes: 1

Related Questions