2012-05-24 5 views

답변

4

내가이 그룹을 통해 반복하고 그들 모두의 상태를 저장 :

상태 복원을 위해 다음
int numberOfGroups = MyExpandableListViewAdapter.getGroupCount(); 
boolean[] groupExpandedArray = new boolean[numberOfGroups]; 
    for (int i=0;i<numberOfGroups;i++) 
    groupExpandedArray[i] = MyExpandableListView.isGroupExpanded(i); 

: 난 당신이 액세스하는 방법에 의해 무슨 뜻인지 이해하지

for (int i=0;i<groupExpandedArray.length;i++) 
    if (groupExpandedArray[i] == true) 
    MyExpandableListView.expandGroup(i); 

을 onPause()/onResume()의 ListView, ListView 객체를 액티비티 클래스의 멤버로 저장하면 거기에서 액세스 할 수 있어야합니다.

+0

예 Floaf, 이미 해결책을 찾았습니다. :) – mrd

0

당신은 단지 그것을 확인하고 적절하게 대응 나중에 마지막으로 선택한 ChildPosition 및 GroupPositin 정수를 유지하고 setOnGroupClickListner 및 setOnChildClickListener를 사용하는 경우 간단한 방법이 될 수

if (childPosition > 0) { 
    mExpandableList.expandGroup(groupPositin); 
} 
mExpandableList.setItemChecked(groupPositin + childPosition , true); 

당신은 childPosition을 설정 기억할 필요 setOnGroupListener 메소드에서 0으로 설정하십시오. Floaf의 답변을 향상

3

: 일시 정지에

public static int firstVisiblePosition=0; 

를 선언

int numberOfGroups = MyExpandableListViewAdapter.getGroupCount(); 
boolean[] groupExpandedArray = new boolean[numberOfGroups]; 
for (int i=0;i<numberOfGroups;i++){ 
    groupExpandedArray[i] = MyExpandableListView.isGroupExpanded(i); 
} 
firstVisiblePosition = MyExpandableListView.getFirstVisiblePosition(); 

onResume

for (int i=0;i<groupExpandedArray.length;i++){ 
    if (groupExpandedArray[i] == true) 
     MyExpandableListView.expandGroup(i); 
} 
MyExpandableListView.setSelection(firstVisiblePosition); 

이 각 그룹의 상태를 복원하지 않습니다 그러나 또한 childView로 이동 한 것 활동이 일시 중지되었을 때 조회되었습니다.

관련 문제