私はこのようなことをしました。試すこともできます。そのうまく機能
public boolean onTouchEvent(MotionEvent ev) {
final int action = ev.getAction();
if ((action == MotionEvent.ACTION_MOVE) && (mTouchState != TOUCH_STATE_REST)) {
Log.d("DB", " scrolling twice ");
scrolltwice = true;
return true;
}
final float x = ev.getX();
final float y = ev.getY();
switch(action & MotionEvent.ACTION_MASK){
case MotionEvent.ACTION_MOVE:
final int xDiff = (int) Math.abs(x - mLastMotionX);
yDiff = (int) (y - mLastMotionY);
final int ydif = (int) Math.abs(y - mLastMotionY);
final int touchSlop = mTouchSlop;
boolean xMoved = xDiff > touchSlop;
boolean yMoved = ydif > touchSlop;
if (xMoved || yMoved) {
if (yMoved) {
mTouchState = TOUCH_STATE_SCROLLING;
}
}
break;
case MotionEvent.ACTION_DOWN:
if (!mScroller.isFinished()) {
mScroller.abortAnimation();
}
// Remember location of down touch
mLastMotionX = x;
mLastMotionY = y;
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
final int myDiff = (int) (y - mLastMotionY);
if(mTouchState == TOUCH_STATE_SCROLLING){
scrolltwice = false;
if(!scrolltwice){
Log.d("DB", " ACTION_UP fetch new records ");
FetchRecords rec = new FetchRecords();
rec.execute();
if(yDiff < 0){ // fetching next slot of records
nextRecordId = nextRecordId + previousTotal;
if(nextRecordId > totalRowCount){
nextRecordId = nextRecordId - previousTotal;
}
}else if(yDiff > 0){ // fetching previous slot of records
nextRecordId = nextRecordId - previousTotal;
if(nextRecordId < 1){
nextRecordId = 0;
}
}
}
}
scrolltwice = false;
mTouchState = TOUCH_STATE_REST;
break;
}
return false;
}
//implement ontouch listener if the view is list pass it onTouchEvent
public boolean onTouch(View v, MotionEvent event) {
if(v.equals(objListView))
onTouchEvent(event);
return false;
}