listview onscroll 的使用
public class myScrollListener implements OnScrollListener {
int nowid;
List<HouseBean> nbst = null;
Handler handler = new Handler();
@Override
public void onScrollStateChanged(AbsListView paramAbsListView,
int scrollState) {
if (isLastRow && scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
//显示进度条
Building.this.pb.setVisibility(View.VISIBLE);
page.getAndAdd(1);
isLastRow = false;
//hander异步加载
Message msg=new Message();
msg.what=type;
msg.arg1=nowid;
lhand.sendMessage(msg);
}
}
boolean isLastRow = false;
@Override
public void onScroll(AbsListView paramAbsListView,
int firstVisibleItem, int visibleItemCount, int totalItemCount) {
// pb.setVisibility(View.VISIBLE);
nowid = totalItemCount;
if (firstVisibleItem + visibleItemCount == totalItemCount
&& totalItemCount > 0) {
isLastRow = true;
}
}
}