Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxwin-z committed Jun 27, 2012
1 parent cdff7f6 commit c6f79ae
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

# Project target.
target=android-7
android.library=false
2 changes: 2 additions & 0 deletions src/me/maxwin/XListViewActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public void onCreate(Bundle savedInstanceState) {
mListView.setPullLoadEnable(true);
mAdapter = new ArrayAdapter<String>(this, R.layout.list_item, items);
mListView.setAdapter(mAdapter);
// mListView.setPullLoadEnable(false);
// mListView.setPullRefreshEnable(false);
mListView.setXListViewListener(this);
mHandler = new Handler();
}
Expand Down
9 changes: 3 additions & 6 deletions src/me/maxwin/view/XListView.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class XListView extends ListView implements OnScrollListener {

// -- footer view
private XListViewFooter mFooterView;
private RelativeLayout mFooterViewContent;
private boolean mEnablePullLoad;
private boolean mPullLoading;
private boolean mIsFooterReady = false;
Expand Down Expand Up @@ -98,8 +97,6 @@ private void initWithContext(Context context) {

// init footer view
mFooterView = new XListViewFooter(context);
mFooterViewContent = (RelativeLayout) mFooterView
.findViewById(R.id.xlistview_footer_content);

// init header height
mHeaderView.getViewTreeObserver().addOnGlobalLayoutListener(
Expand Down Expand Up @@ -133,7 +130,7 @@ public void setPullRefreshEnable(boolean enable) {
if (!mEnablePullRefresh) { // disable, hide the content
mHeaderViewContent.setVisibility(View.INVISIBLE);
} else {
mFooterViewContent.setVisibility(View.VISIBLE);
mHeaderViewContent.setVisibility(View.VISIBLE);
}
}

Expand All @@ -145,11 +142,11 @@ public void setPullRefreshEnable(boolean enable) {
public void setPullLoadEnable(boolean enable) {
mEnablePullLoad = enable;
if (!mEnablePullLoad) {
mFooterViewContent.setVisibility(View.INVISIBLE);
mFooterView.hide();
mFooterView.setOnClickListener(null);
} else {
mPullLoading = false;
mFooterViewContent.setVisibility(View.VISIBLE);
mFooterView.show();
mFooterView.setState(XListViewFooter.STATE_NORMAL);
// both "pull up" and "click" will invoke load more.
mFooterView.setOnClickListener(new OnClickListener() {
Expand Down
18 changes: 18 additions & 0 deletions src/me/maxwin/view/XListViewFooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ public void loading() {
mProgressBar.setVisibility(View.VISIBLE);
}

/**
* hide footer when disable pull load more
*/
public void hide() {
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)mContentView.getLayoutParams();
lp.height = 0;
mContentView.setLayoutParams(lp);
}

/**
* show footer
*/
public void show() {
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)mContentView.getLayoutParams();
lp.height = LayoutParams.WRAP_CONTENT;
mContentView.setLayoutParams(lp);
}

private void initView(Context context) {
mContext = context;
LinearLayout moreView = (LinearLayout)LayoutInflater.from(mContext).inflate(R.layout.xlistview_footer, null);
Expand Down

0 comments on commit c6f79ae

Please sign in to comment.