Multi level view: expandablelistview

情到浓时终转凉″ 提交于 2020-01-01 07:04:54

问题


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


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

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




回答2:


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.



来源:https://stackoverflow.com/questions/5639090/multi-level-view-expandablelistview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!