第一种 滑动的时候不会停顿
listView.setOnScrollListener(newOnScrollListener(){
@Override
publicvoidonScrollStateChanged(AbsListViewview,intscrollState){
}
@Override
publicvoidonScroll(AbsListViewview,intfirstVisibleItem,intvisibleItemCount,inttotalItemCount){
intlastVisibleItem=firstVisibleItem+visibleItemCount;
if(this.scrollState==OnScrollListener.SCROLL_STATE_IDLE
&&totalItemCount>0&&lastVisibleItem==totalItemCount){
list.addAll(getMoreData());
adapter.notifyDataSetChanged();
}
}
});
第二种
listView.setOnScrollListener(newOnScrollListener(){
@Override
publicvoidonScrollStateChanged(AbsListViewview,intscrollState){
//当不滚动时
if(scrollState==OnScrollListener.SCROLL_STATE_IDLE){
//判断是否滚动到底部
if(view.getLastVisiblePosition()==view.getCount()-1){
//loadMoreDatas
adapter.notifyDataSetChanged();
}
}
}
@Override
publicvoidonScroll(AbsListViewview,intfirstVisibleItem,
intvisibleItemCount,inttotalItemCount){}
});