/** * 启用或禁用加载更多的功能. * * @param enable */ public void setPullLoadEnable(boolean enable) { mEnablePullLoad = enable; if (!mEnablePullLoad) { mFooterView.hide(); // 隐藏 mPullLoading = false; mFooterView.setState(XListViewFooter.STATE_NORMAL); // both "上拉" 和 "点击" 将调用加载更多. mFooterView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { startLoadMore(); } }); } else { mPullLoading = false; mFooterView.show(); // 显示 mFooterView.setState(XListViewFooter.STATE_NORMAL); // both "上拉" 和 "点击" 将调用加载更多. mFooterView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { startLoadMore(); } }); } }
// 改变底部视图高度 private void updateFooterHeight(float delta) { int height = mFooterView.getBottomMargin() + (int) delta; if (mEnablePullLoad && !mPullLoading) { if (height > PULL_LOAD_MORE_DELTA) { // 高度足以调用加载更多 mFooterView.setState(XListViewFooter.STATE_READY); } else { mFooterView.setState(XListViewFooter.STATE_NORMAL); } } mFooterView.setBottomMargin(height); // setSelection(mTotalItemCount - 1); // scroll to bottom }
private void startLoadMore() { mPullLoading = true; mFooterView.setState(XListViewFooter.STATE_LOADING); if (mListViewListener != null) { mListViewListener.onLoadMore(); } }
/** * enable or disable pull up load more feature. * * @param enable */ public void setPullLoadEnable(boolean enable) { mEnablePullLoad = enable; if (!mEnablePullLoad) { mFooterView.hide(); mFooterView.setOnClickListener(null); } else { mPullLoading = false; mFooterView.show(); mFooterView.setState(XListViewFooter.STATE_NORMAL); // both "pull up" and "click" will invoke load more. mFooterView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startLoadMore(); } }); } }
/** stop load more, reset footer view. */ public void stopLoadMore() { if (mPullLoading == true) { mPullLoading = false; mFooterView.setState(XListViewFooter.STATE_NORMAL); } }
public void loadComplete() { if (mPullLoading == true) { mFooterView.setState(XListViewFooter.STATE_COMPLETE); } }