Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Custom OnScrollListener forcing the section header scrolling #56

Open
arinjaypatni-infy opened this issue Jan 20, 2017 · 1 comment

Comments

@arinjaypatni-infy
Copy link

Hi,

I have added my custom OnScrollListener which is AbsListView.OnScrolllistener on HeaderListView ,because its own onscrolllistener is required for minimum Api LEVEL 23(my minimum is 15).
It is forcing the section headers scrolling.I want to fix the sectional headrers.Kindly give me some advice.

Below is my custom implementation:-
MyClass implements AbsListView.OnScrollListener
{
@Bind(R.id.receipt_list)
HeaderListView mReceiptsList;

    mReceiptsList.getListView().setOnScrollListener(this);

@OverRide
public void onScrollStateChanged(AbsListView view, int scrollState) {
this.currentScrollState = scrollState;
this.isScrollCompleted();//the method to detect scroll completion
}

@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    this.currentFirstVisibleItem = firstVisibleItem;
    this.currentVisibleItemCount = visibleItemCount;
    this.totalItemCount = totalItemCount;
}

   /***By this methos I detect if there's been a scroll which has completed***/
private void isScrollCompleted() {
    if (this.currentVisibleItemCount > 0 && this.currentScrollState == SCROLL_STATE_IDLE && this.totalItemCount == (currentFirstVisibleItem + currentVisibleItemCount)) {
 
        if(canLoad) { //class variables to manipulate the data
            pageNumber =pageNumber +1;
            refreshScreen();
        }
    }
}

}

@mortenholmgaard
Copy link

I have had a similar problem I think. It worked more like expected for me when I set the listener directly on the HeaderListView.

mReceiptsList.setOnScrollListener(this);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants