I’m trying to subclass an ExpandableListView so that I can add distinct groups.
By distinct groups, I mean that each group contains a different child view type (where all the childeren are the same throughout a group).
That is:
Group 1
TextView 1
TextView 2
TextView 3
Group 2
EditText 1
EditText 2
EditText 3
...
I tried stacking two ELV ontop of each other in a LinearLayout, however the main behavior I’m trying to obtain (which is the only reason I’m using a ELV in the first place) is lossed: each list becomes independently scrollable, where if a single ELV is used that contains multiple groups, they will all scroll together).
I’ve already seen the post
How to add image in expandable List in parent in android?
However this isn’t quite what I’m looking for. This solves the problem for multiple, distinct children within a group:
Group 1
TextView 1
Image 1
----------
TextView 2
Image 2
...
I’m sure with enough time I might be able to figure it out from this, but I wanted to see if anyone has already done it before.
I already implemented my ELV adapter and got everything compiling and running ok, and am now ready to adapt the code to solve this particular problem.
Thank you.
there’s no support for that from android. one common approach is to make a wrapper object for you list elements. for example, suppose you want to show
Cars andPersons in the list, then you’d do something likeat runtime, either
carorpersonis null. in your implementation ofgetView(), you do something like,if you use your convert view (which you should), you have to be careful. for example, if convert view was inflated for a
Car, and you are supposed to be getting a view for aPerson. a way to handle this is to create an uber view that contains bothCarandPersonviews, and then you just hide or show the respective part ingetView().another way is to have two separate expandable
ListViews.