Reputation: 125
can anyone tell me why I can not get onOverScrolled be called in my following code:
public class KasOverScrollListenableListView extends ListView {
public interface OverScrollListener{
void onOverScroll(int scrollx, int scrollY,boolean clampedX, boolean clampedY );
}
private OverScrollListener mOverScrollListener= null;
public KasOverScrollListenableListView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
public KasOverScrollListenableListView(Context context, AttributeSet attrs){
this(context,attrs,0);
}
public KasOverScrollListenableListView(Context context){
this(context,null,0);
}
protected void onOverScroll(int scrollX, int scrollY, boolean clampedX, boolean clampedY){
Log.i("overScrolling", "overScrolling is " + scrollY);
// if the version of the system higher than 2.3 then do the following things.
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD){
// super.onOverScrolled(scrollX, scrollY, clampedX, clampedY);
if(null != mOverScrollListener ){
mOverScrollListener.onOverScroll(scrollX, scrollY, clampedX, clampedY);
}
}
}
public void setOnOverScrollListener(OverScrollListener listener){
mOverScrollListener = listener;
}
}
I can never get the log to be output which means this function never been called, while this listview is actually overscrolled.I will really be grateful to hear your idea.
Upvotes: 2
Views: 3445
Reputation: 3430
The method is onOverScrolled
, not onOverScroll
.
You can detect these bugs by putting @Override
above the method signature. The compiler will let you know if you really are overriding a method or not.
Upvotes: 0
Reputation: 5672
Just...if it will needed someone. I shared working sample on Github.
Works fine on 2.3+
Upvotes: 0
Reputation: 1141
Not sure if this will help, but the example in the below link calls super.overScrollBy(...). I am able to get to onOverScroll using this code. Hope it helps...
OverScroll ListView Sample code
Upvotes: 1