关闭所有组除了在扩展列表视图android的选定组 [英] Collapse all group except selected group in expandable listview android
本文介绍了关闭所有组除了在扩展列表视图android的选定组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发使用可扩展列表视图android应用。其实我需要的是,我列出组,其中包含子。
I'm developing android application using expandable list view. Actually what I need is, I'm listing group, which contains child.
如果我选择unexpandable组,应该扩大后,我会在那个时候,第一组应折叠选择第二组。我做了谷歌,但我找不到我想要的。请帮我。
If I select an unexpandable group, it should expand, after I ll select second group at that time the first group should be collapsed. I did Google, but I couldn't find what I want. Please help me out.
推荐答案
有存储在一个变量的当前扩大集团的立场。在onGroupExpanded做到以下几点。
Have the current expanded group position stored in a variable. In onGroupExpanded do the following.
private int lastExpandedPosition = -1;
private ExpandableListView lv; //your expandable listview
...
lv.setOnGroupExpandListener(new OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
if (lastExpandedPosition != -1
&& groupPosition != lastExpandedPosition) {
lv.collapseGroup(lastExpandedPosition);
}
lastExpandedPosition = groupPosition;
}
});
这篇关于关闭所有组除了在扩展列表视图android的选定组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文