本帖最后由 wu55uw 于 2012-05-17 09:49:08 编辑

解决方案 »

  1.   

    class GVIntGestureListener implements OnGestureListener,OnTouchListener {
    private GestureDetector mGestureDetector;
    public GVIntGestureListener() {
    mGestureDetector = new GestureDetector(mLauncher,this);
    mGestureDetector.setIsLongpressEnabled(false);  
    }
    public boolean onDown(MotionEvent e) {
    Log.i("Down","Down");
    return false;
    } public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
    Log.i("onFling","onFling");
    if(Math.abs(velocityX)>Math.abs(velocityY ) && mDragView==null && !mbIsDraging){
    //当前滑动的子控件索引
    int FlingChildIndex = pointToPosition((int) e2.getX(), (int) e2.getY());
    TubiaoElementInfo tElement = new TubiaoElementInfo(); //最后一个元素为“添加”,不处理其滑动事件
    if(FlingChildIndex!=INVALID_POSITION && FlingChildIndex < mAdapter.getCount() - 1){
    tElement = (TubiaoElementInfo)mAdapter.getItem(FlingChildIndex);
    View item = getChildAt(FlingChildIndex - getFirstVisiblePosition());
    mDragger.startDrag(item, GridViewInterceptor.this, tElement, DragController.DRAG_ACTION_MOVE);
    //在滑动开始后禁用GridViewInterceptor,这样它就不能接收到Touch操作
    setEnabled(false);
    mbIsDraging = true;
    }
    }
    return true;
    } public void onLongPress(MotionEvent e) {
    Log.i("onLongPress","onLongPress");
    } public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
    Log.i("onScroll","distanceX"+distanceX+"distanceY"+distanceY);
    if(Math.abs(distanceX)>Math.abs(distanceY) && mDragView==null && !mbIsDraging){
    //当前滑动的子控件索引
    int FlingChildIndex = pointToPosition((int) e2.getX(), (int) e2.getY());
    TubiaoElementInfo tElement = new TubiaoElementInfo(); //最后一个元素为“添加”,不处理其滑动事件
    if(FlingChildIndex!=INVALID_POSITION && FlingChildIndex < mAdapter.getCount() - 1){
    tElement = (TubiaoElementInfo)mAdapter.getItem(FlingChildIndex);
    ViewGroup item = (ViewGroup) getChildAt(FlingChildIndex - getFirstVisiblePosition());
    mDragger.startDrag(item, GridViewInterceptor.this, tElement, DragController.DRAG_ACTION_MOVE);
    //在滑动开始后禁用GridViewInterceptor,这样它就不能接收到Touch操作
    setEnabled(false);
    mbIsDraging = true;
    }
    }
    return false;
    }