HeaderListView icon indicating copy to clipboard operation
HeaderListView copied to clipboard

Adding Custom OnScrollListener forcing the section header scrolling

Open arinjaypatni-infy opened this issue 9 years ago • 1 comments

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();
        }
    }
}

}

arinjaypatni-infy avatar Jan 20 '17 08:01 arinjaypatni-infy

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);

mortenholmgaard avatar Jul 17 '17 15:07 mortenholmgaard