I am planning to create an expandable Listview
that has more than 2 levels. How can I do this?
Asked
Active
Viewed 2,917 times
2

Jason Plank
- 2,336
- 5
- 31
- 40

James
- 13,891
- 26
- 68
- 93
1 Answers
1
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.
-
1Surely that should be ExpandableListView, not BaseExpandableListAdapter in the convertView? – Phil Lello Apr 15 '11 at 17:56
-
1Thanks for pointing that out! :) stupid mistake, i've corrected it – rekaszeru Apr 15 '11 at 18:00
-
You missed one (directly below the override) - I've tried to edit for you, it's stuck in peer review ATM – Phil Lello Apr 15 '11 at 21:05
-
Thanks rekaszeru, I will try out that. – James Apr 16 '11 at 01:18
-
Can you give me a little sample here. I am so stucked. – Andro Selva Jul 29 '11 at 04:51