下面的方法在ListView外面能用, 自定义ListView里面不能用.
private OnScrollListener myListener = new OnScrollListener() {
public void onScrollStateChanged(AbsListView view, int scrollState) {
switch (scrollState) {
// 当不滚动时
case OnScrollListener.SCROLL_STATE_IDLE:
// 判断滚动到底部
if (getLastVisiblePosition() == (getCount() - 1)) {
Log.i("Inner", "bottom-------------------");
setParentScrollAble(true);
}
// 判断滚动到顶部
if (getFirstVisiblePosition() == 0) {
Log.i("Inner", "top-------------------");
setParentScrollAble(true);
}
break;
}
}
@Override
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
Log.i("Inner", "scroll-------------------");
//setParentScrollAble(false);
if (firstVisibleItem + visibleItemCount == totalItemCount && !flag) {
flag = true;
} else
flag = false;
}
};