How to implement DoubleClick on Android EditText?

前端 未结 1 669
借酒劲吻你
借酒劲吻你 2021-01-06 23:11

I have an \"Activity1\" which has an \"EditText\". I want to open another activity \"Activity2\" when the user Double clicks on the \"EditText\".

1条回答
  •  旧巷少年郎
    2021-01-06 23:50

    Use this:

    final GestureDetector gestureDetector = new GestureDetector(context,new GestureDetector.SimpleOnGestureListener() {
        public boolean onDoubleTap(MotionEvent e) {
            Log.e("", "Open new activty here");
            return true;
        }
    });
    TextView tv = (TextView) findViewById(R.id.editTextID);
    tv.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
        }
    });
    

    0 讨论(0)
提交回复
热议问题