android-如何检测双击imageview并启动新片段

android-如何检测双击imageview并启动新片段,android,android-fragments,imageview,motionevent,gesturedetector,Android,Android Fragments,Imageview,Motionevent,Gesturedetector,我在这个主题上做了很多搜索,甚至还参考了android开发者网站上的官方文档。但概念还不清楚 我已经读到,为了实现触摸手势,我需要使用GestureDetector和MotionEvent软件包。但它的实施让我对这些事情感到困惑 我想要的是,我的布局包括许多文本视图和两个图像视图。我想检测我的图像上的双击,并想开始一个新的片段活动。在新的片段活动中,我想在横向模式下全屏显示相同的图像 我读了很多书,但它使我感到困惑。 请帮忙。 谢谢这里是双击手势图像视图 public class CustomI

我在这个主题上做了很多搜索,甚至还参考了android开发者网站上的官方文档。但概念还不清楚

我已经读到,为了实现触摸手势,我需要使用GestureDetector和MotionEvent软件包。但它的实施让我对这些事情感到困惑

我想要的是,我的布局包括许多文本视图和两个图像视图。我想检测我的图像上的双击,并想开始一个新的片段活动。在新的片段活动中,我想在横向模式下全屏显示相同的图像

我读了很多书,但它使我感到困惑。 请帮忙。
谢谢

这里是双击手势图像视图

public class CustomImageView extends ImageView {
    private Context context;
    private GestureListener mGestureListener;
    private GestureDetector mGestureDetector;

    public CustomImageView(Context context) {
        super(context);
        sharedConstructing(context);
    }

    public CustomImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
        sharedConstructing(context);
    }

    public CustomImageView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        sharedConstructing(context);
    }

    private void sharedConstructing(Context context) {
        super.setClickable(true);
        this.context = context;
        mGestureListener=new GestureListener();
        Log.e("Adding", "Listener:::");
        mGestureDetector = new GestureDetector(context, mGestureListener, null, true);
        setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                mGestureDetector.onTouchEvent(event);
                //..my other code logic
                invalidate();
                return true; // indicate event was handled
            }

        });
    }

    public class GestureListener extends GestureDetector.SimpleOnGestureListener {

        @Override
        public boolean onDoubleTap( MotionEvent e ) {
            // TODO DoubleTap Comparison 
            Log.e("onDoubleTap","onDoubleTap");
            return true;
        }
    }

}

请展示您尝试过的内容。这里有几个可用的工作示例。请参考此链接:您会得到它。@SilentKiller我还没有尝试过它。我只是想学first@user3794646然后你应该先在谷歌上搜索,然后把问题贴在上面我想将其添加到特定的imageview对象上。上面的代码会朝着期望的方向工作吗?我想在设置中像android一样进入开发者模式。如何实现这一点。如果用户在imageview或任何视图上点击7次。然后只做某些事情,否则什么也不做。