Setting a scroll listener on an Android AbsListView causes that listener to be invoked immediately. This is clearly intentional from the source of AbsListView.java
:
public void setOnScrollListener(OnScrollListener l) {
mOnScrollListener = l;
invokeOnItemScrollListener();
}
Why would anyone want this?
Setting a click/touch listener doesn't cause the listener to be called immediately, why are scroll listeners different? Is there some reasonable rationale for this that I'm missing?
Related question in which someone's bitten by this weird behavior: onScroll gets called when I set listView.onScrollListener(this), but without any touch