반응형

출처: http://stackoverflow.com/questions/3014089/maintain-save-restore-scroll-position-when-returning-to-a-listview


위의 링크의 두 번째 답변을 참고하여 다음과 같은 소스를 작성하면 된다.


1
2
3
4
5
6
7
8
9
10
11
12
13
Parcelable state; // 상태 저장 변수
 
...
 
public void onPause() {
    state = listView.onSaveInstanceState(); // 리스트뷰 스크롤 위치 저장
}
 
public void onResume() {
    if (state != null) { // 리스트뷰 상태가 있는 경우
        listView.onRestoreInstanceState(state); // 리스트뷰 스크롤 위치 복구
    }
}
반응형
Posted by 애콜라이트
l

free counters