static int first,last;//定义第一个和最后一个位置。
getListView().setOnScrollListener(new OnScrollListener() {
public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub
if(scrollState==OnScrollListener.SCROLL_STATE_IDLE){
last=getListView().getLastVisiblePosition();
first=getListView().getFirstVisiblePosition();
}
}
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
}
});
getListView().setSelectionFromTop(first, last);
}