我的 setOnScrollListener 有问题。每当我滚动到列表视图的底部时,它就会一直调用我的异步任务。如何将 setOnScrollListener 设置为仅在到达底部时才加载。
listview.setAdapter(adapter);
mProgressDialog.dismiss();
listview.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
int lastInScreen = firstVisibleItem + visibleItemCount;
if (lastInScreen == totalItemCount) {
new loadmore().execute();
} else {
}
}
);