2014-09-11 183 views
0

您好我是新來的Android應用程序現在我在維護ExpandableListView。該組沒有崩潰,請讓我知道如何解決這個問題的來襲,在此先感謝ExpandableListView展開和摺疊

下面是代碼我處理,如果任何錯誤在該代碼,請讓我知道

@Override 
public void onGroupCollapsed(int groupPosition) { 
super.onGroupCollapsed(groupPosition); 
} 

@Override 
public void onGroupExpanded(int groupPosition) { 

    //if(IsExpanded) 
    //{ 
     if(lastExpandedGroupPosition != -1 && groupPosition != lastExpandedGroupPosition){ 
      onGroupCollapsed(lastExpandedGroupPosition); 
      } 
     else { super.onGroupExpanded(groupPosition); } 
    //} 

    lastExpandedGroupPosition = groupPosition; 

} 

回答

3

中如果

​​

聲明insteed嘗試

listView.collapseGroup(lastExpandedGroupPosition); 

或我看你要崩潰了擴展鬱可使用類似這樣

public void onGroupExpand(int groupPosition) { 
    int lenght = adapter.getGroupCount(); 
    for (int i = 0; i < lenght; i++) { 
     if (i != groupPosition) { 
      listView.collapseGroup(i); 
     } 
    } 
} 
所有exept