Multi level view: expandablelistview

2020-06-24 01:00发布

I am trying to write multi level tree. I did look at expandablelistview, but it only supports two levels. I did look at other questions(SO) & posts and the most promising post i have found is http://mylifewithandroid.blogspot.com/2011/02/3-level-expandable-lists.html

I understand that i will have to write something custom to handle multiple level tree. What is the best recommended approach to take? Can i add an exapandablelistview as a child to an exapanablelistview??

Thanks

2条回答
成全新的幸福
2楼-- · 2020-06-24 01:51

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 a BaseExpandableListAdapter instance to the convertView, and return it.

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

查看更多
家丑人穷心不美
3楼-- · 2020-06-24 01:51

It's possible, but it would make the GUI structure too complicated to implement.

First, you have to know that the items rendered of ExpandableListView are given by a BaseExpandableListAdapter. You have to design and implement the same number of adapters as your level-2 items, so that the level-3 lists can be rendered correctly for each level-2 item.

I would suggest you to redesign the GUI. Multilevel ExpandableListView not only complicate the code, maybe also mess up the screen.

查看更多
登录 后发表回答