给listview设置滑动监听器,来判断内容滑动到底部或者顶部listview.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if(firstVisibleItem==0){
Log.e("log", "滑到顶部");
}
if(visibleItemCount+firstVisibleItem==totalItemCount){
Log.e("log", "滑到底部");
}
}
});
根据这个方法检测:
[java]
getListView().setOnScrollListener(new OnScrollListener() {
@Override www.2cto.com
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if(firstVisibleItem==0){
Log.e("log", "滑到顶部");
} www.2cto.com
if(visibleItemCount+firstVisibleItem==totalItemCount){
Log.e("log", "滑到底部");
}
}
});