public void initFootView() {
mfootView = View.inflate(getContext(), R.layout.refresh_footer, null);
addFooterView(mfootView);
mfootView.measure(0, 0);
footMeasureHeight = mfootView.getMeasuredHeight();
mfootView.setPadding(0, -footMeasureHeight, 0, 0);
this.setOnScrollListener(this); // listView 实现onScrollListener.滑动监听。
}
滑动状态:
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub
if(scrollState==SCROLL_STATE_IDLE||scrollState==SCROLL_STATE_FLING){
if(getLastVisiblePosition()==getCount()-1){
Log.e("RefreshListView", "到底了");
mfootView.setPadding(0, 0, 0, 0);
setSelection(getCount()-1); //这个表示设置选中的位置。超级实用。
}
}
}