是通过onFling方法吗?

解决方案 »

  1.   


    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
    float velocityY) {
    // TODO Auto-generated method stub
    Log.i("Fling", "Fling Happened!");
    if (e1.getX() - e2.getX() > 120) {
    this.flipper.setInAnimation(AnimationUtils.loadAnimation(this,R.anim.push_left_in));
    this.flipper.setOutAnimation(AnimationUtils.loadAnimation(this,R.anim.push_left_out));
    this.flipper.addView(addTextByText("�ı���"),new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    this.flipper.showNext();
    return true;
    } else if (e1.getX() - e2.getX() < -120) {
    this.flipper.setInAnimation(AnimationUtils.loadAnimation(this,R.anim.push_right_in));
    this.flipper.setOutAnimation(AnimationUtils.loadAnimation(this,R.anim.push_right_out));
    this.flipper.showPrevious();
    return true;
    }
    return true;
    } }
    _________________
    当onFling触发时,大概e1是down的事件,e2是up的事件, 用事件的getX(),可以得到当前位置吧,减就是滑动距离了吧~