开发者

differentiating left and right scroll in gallery

Hie all , is there any method in android that can differentiate the left and the right scrolling actions in android.

differentiating left and right scroll in gallery

it is actually a customized gallery view so what I am trying to do is that on scroll actions i want to differen开发者_StackOverflow社区t images. I mean on left scroll I've different images and on right scroll I've different images to show. so i need to differentiate the let and right scroll.


Try this code:

new OnTouchListener() {

            @Override
            public boolean onTouch(View currentView, MotionEvent touchevent) {
                switch (touchevent.getAction())
                {
                case MotionEvent.ACTION_DOWN:
                {
                    oldTouchValue = touchevent.getX();
                    break;
                }
                case MotionEvent.ACTION_UP:
                {
                    float currentX = touchevent.getX();

                    if((oldTouchValue - currentX) < 50 && (oldTouchValue - currentX) > -50) {
                        return false;
                    }
                    if (oldTouchValue < currentX)
                    {
                        // Left swipe...
                    }
                    if (oldTouchValue > currentX)
                    {
                        // Right swipe
                    }
                    break;
                }
                }
                return false;
            }
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜