本文介绍了Android的多点触摸,并双击合作了一个ImageView的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜我有一个的LinearLayout(垂直方向)两个imageviews。我设置setOnTouchListener同时为Imageviews。这样我能够观察到多点触摸缩放,以及在ImageViews的所有拖动。问题来了,当我试图实现OnDoubletapListener。只有OnDoubleTapListener作品,未经使用setOnTouchListener的。

HiI have two imageviews in a LinearLayout(Vertical orientation). I am setting setOnTouchListener for both the Imageviews.This way i am able to observe the Multi touch zoom as well as all the dragging of the ImageViews.The problem comes when i try to implement OnDoubletapListener.OnDoubleTapListener works only without the use of setOnTouchListener.

但是,如果我评论的setOnTouchListner那么我能够执行枪王。

However if i comment the setOnTouchListner then i am able to perform Double Tap..

不能两个feartures同时工作?????

Can't the two feartures work simultaneously?????

如果你想我可以提供源$ C ​​$ C以及..PL帮助

If You want i can provide the source code as well..Pl Help

ANKIT维尔马

推荐答案

我也遇到了相同类型的问题....我解决这个办法...

I had also face that same type problem....I solve with this way...

如果您使用的Andr​​oid mutitouch控制器的http:// code .google.com / P / Android的多点触控控制器/ 多点触控

If You using android mutitouch controller http://code.google.com/p/android-multitouch-controller/ for multitouch

和GestureDetector http://www.41post.com/ 4194 /程序/ Android的检测,双击,事件了解双击

and GestureDetector http://www.41post.com/4194/programming/android-detecting-double-tap-events for double tap

在MultiTouchController.java更新这个步骤

update this steps in MultiTouchController.java

- >导入

  import android.view.GestureDetector.OnDoubleTapListener;

  import android.view.GestureDetector.OnGestureListener;

- >实施

--> implement

 public class MultiTouchController<T> implements OnGestureListener{

- >

-->

public MultiTouchController(MultiTouchObjectCanvas<T> objectCanvas2, boolean handleSingleTouchEvents) {

           //....

    gd = new GestureDetector(this);

    // set the on Double tap listener
    gd.setOnDoubleTapListener(new OnDoubleTapListener() {
        @Override
        public boolean onDoubleTap(MotionEvent e) {
            // set text color to green
            Log.d("CLICK", "double taped");



            return false;
        }

        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            // if the second tap hadn't been released and it's being moved
            if (e.getAction() == MotionEvent.ACTION_MOVE) {
                Log.d("CLICK", "double tap event ACTION_MOVE");
            } else if (e.getAction() == MotionEvent.ACTION_UP)// user
                                                                // released
                                                                // the
                                                                // screen
            {
                Log.d("CLICK", "double tap event ACTION_UP");
            }
            return false;
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            // set text color to red
            Log.d("CLICK", "single taped");

            return true;
        }
    });

- >设置触摸事件的gd在onTouch(MotionEvent事件)

--> set touch event to gd at onTouch(MotionEvent event)

   public boolean onTouchEvent(MotionEvent event) {

    gd.onTouchEvent(event);

    try {

               //.....

不要在任何其他文件更改。

Don't change in any other files.

现在测试...希望你解决问题......必须回复...

Now test...Hope you solved problem...must reply...

这篇关于Android的多点触摸,并双击合作了一个ImageView的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 08:17