smoothScrollToPositionFromTop (int position, int offset) > 안드로이드 플랫폼 지식 공유

본문 바로가기
사이트 내 전체검색


회원로그인

My IP : 3.144.20.66
[Sponsor]
DNS Powered by DNSEver.com



[Admin Email]

* 문서저장소 바로가기 *
* 2015년 이전 웹페이지 *
안드로이드 플랫폼 지식 공유

smoothScrollToPositionFromTop (int position, int offset)

페이지 정보

작성자 LUG 작성일14-12-05 15:57 조회16,666회 댓글0건

본문

public void smoothScrollToPositionFromTop (int position, int offset)

Added in API level 11 

 

Smoothly scroll to the specified adapter position. The view will scroll such that the indicated position is displayed offset pixels below the top edge of the view. If this is impossible, (e.g. the offset would scroll the first or last item beyond the boundaries of the list) it will get as close as possible.

 

Parameters

position Position to scroll to

offset Desired distance in pixels of position from the top of the view when scrolling is finished 

 

public void smoothScrollToPosition (int position)

Added in API level 8

 

Smoothly scroll to the specified adapter position. The view will scroll such that the indicated position is displayed.

 

Parameters

position Scroll to this adapter position. 

 

public void setSelectionFromTop (int position, int y)

Added in API level 1

 

Sets the selected item and positions the selection y pixels from the top edge of the ListView. (If in touch mode, the item will not be selected but it will still be positioned appropriately.)

 

Parameters

position Index (starting at 0) of the data item to be selected.

y The distance from the top edge of the ListView (plus padding) that the item will be positioned. 

 

===

 

try {

if (Build.VERSION.SDK_INT >= 11) {

main_lv_filelist.smoothScrollToPositionFromTop(pos, 0);

} else if (Build.VERSION.SDK_INT >= 8) {

int firstVisible = main_lv_filelist.getFirstVisiblePosition();

   int lastVisible = main_lv_filelist.getLastVisiblePosition();

   if (pos < firstVisible) {

main_lv_filelist.smoothScrollToPosition(pos);

   } else {

main_lv_filelist.smoothScrollToPosition(pos + lastVisible - firstVisible - 2);

   }

} else {

main_lv_filelist.setSelectionFromTop(pos, 0);

}

} catch (Exception e) {} 

댓글목록

등록된 댓글이 없습니다.


접속자집계

오늘
27
어제
501
최대
20,159
전체
668,696
한국LUG 소프트웨어 커뮤니티 : http://www.lug.or.kr

커뮤니티소개 개인정보취급방침 서비스이용약관 Copyright © www.lug.or.kr. All rights reserved.
상단으로
모바일 버전으로 보기