Tuesday, March 27, 2012

4-level expandable list views

A while ago I got a question if 3-level expandable list views can be implemented in Android. Android does not explicitly support it but the flexibility of Android UI widget framework provides a relatively simple implementation option: second-level expandable list views are to be inserted into the first-level expandable list view as child views. There was a blog post with an example program and everybody was happy. Even then I made a note that I don't agree with the approach from the UI point of view because the display becomes unnecessarily messy.

Now there was a comment at that blog post whether 4-level lists are possible. Of course they are possible, it is just not a good UI design. But I guess, you better try it yourself if you don't believe me. The principle is the same (expandable lists embedded as children of higher-level expandable lists), it is just much more complex to make sure that everything is recalculated correctly for every event. In order to follow the operation, I left a good amount of debugging code in the project.

Click here to access the example program.


4 comments:

Anonymous said...

ok so I've seen your code for the 3 level list and 4 one, however what I wanted to try is to close an opened level when another of the same level is already opened (this when on groupclicked).
- Red
- red1
-red11
- red2
-red22
-red23

So red 1 and red 2 cannot be opened at the same time. I attempted this but somehow I get an arrayindexoutofbounds when handling the groupclicked and the list.closegroup(x) :S .. how cold I fix this?

Unknown said...
This comment has been removed by the author.
Unknown said...

I want to check-box at 2nd and 3rd level. when we checked any parent check-box then all child of that check-box(Level) should be checked and vice versa. Please Help me.

bhanuprakash said...

how to trigger the click event for the childs i implemneted the onchildclick listener but it didnt worked.....plz plz plz help me out with that