如何在View鳍状肢中用手指滑动?

时间:2013-11-21 08:51:07

标签: android android-layout swipe viewflipper

我有一个包含两个带按钮布局的视图鳍状肢。现在问题是我无法用手指滑动。基本上视图应该与手指一起滑动。我希望你能得到我想说的话。这是onTouchevent代码: -

    bottomFormatFlipper = (ViewFlipper)findViewById(R.id.bottomFormatFlipper);

public boolean onTouchEvent(MotionEvent touchevent) 
    {
        switch (touchevent.getAction())
        {

        // when user first touches the screen to swap
        case MotionEvent.ACTION_DOWN: 
        {
            lastX = touchevent.getX();
            break;
        }
        case MotionEvent.ACTION_UP: 
        {
            float currentX = touchevent.getX();

            // if left to right swipe on screen
            if (lastX < currentX) 
            {
                // If no more View/Child to flip
                if (bottomFormatFlipper.getDisplayedChild() == 0)
                    break;

                // set the required Animation type to ViewFlipper
                // The Next screen will come in form Left and current Screen will go OUT from Right 
                bottomFormatFlipper.setInAnimation(this, R.anim.in_from_left);
                bottomFormatFlipper.setOutAnimation(this, R.anim.out_to_right);
                // Show the next Screen
                bottomFormatFlipper.showNext();
            }

            // if right to left swipe on screen
            if (lastX > currentX)
            {
                if (bottomFormatFlipper.getDisplayedChild() == 1)
                    break;
                // set the required Animation type to ViewFlipper
                // The Next screen will come in form Right and current Screen will go OUT from Left 
                bottomFormatFlipper.setInAnimation(this, R.anim.in_from_right);
                bottomFormatFlipper.setOutAnimation(this, R.anim.out_to_left);
                // Show The Previous Screen
                bottomFormatFlipper.showPrevious();
            }
            break;
        }
        }
        return false;
    }

从此代码中,当我滑动时,大约一秒钟后,会发生滑动动画。我希望视图应该用我的手指轻扫

0 个答案:

没有答案