开发者

Android ImageView Gesture/DoubleTap not firing

Ok, so I have this setup

ScrollView HorizontalScrollView ImageView

I am trying to capture the doubleTap on the Image View.. my code looks like the following:

ImageView iv = (ImageView)findViewById(R.id.ImageViewID);

iv.setImageDrawable(iv.getResources().getDrawable(R.drawable.someimage));
// Gesture detect开发者_运维百科ion
detector = new GestureDetector(this,new SimpleOnGestureListener(){

    //new myGestureClass());

    @Override
    public boolean onSingleTapUp(MotionEvent e) {
        // TODO Auto-generated method stub
        System.out.println("SINGLE TAP");
        return false;
    }

    @Override
    public boolean onDoubleTap(MotionEvent arg0) {
        // TODO Auto-generated method stub
        System.out.println("DOUBLE TAP");
        return false;
    }

    @Override
    public boolean onDoubleTapEvent(MotionEvent arg0) {
        // TODO Auto-generated method stub
        System.out.println("DOUBLE TAP EVENT");
        return false;
    }

    @Override
    public boolean onSingleTapConfirmed(MotionEvent arg0) {
        // TODO Auto-generated method stub
        return false;
    }

});

View.OnTouchListener gestureListener = new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
        System.out.println("TOUCH!" +event);
        if (detector.onTouchEvent(event)) {
            return true;                 
        }   
        return false;
        }
    };

iv.setOnTouchListener(gestureListener); 

Yet the overridden tap methods never get called... The onTouch does get called but the detector.onTouchEvent(event) that should be tying my events to the touch event, never ever calls my overRidden methods.... So, what the heck am I am doing wrong?


Override onDown method and return true. Source

Hope this help.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜