Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement DoubleClick on Android EditText?

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

like image 422
Yaqub Ahmad Avatar asked Dec 06 '25 10:12

Yaqub Ahmad


1 Answers

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);
    }
});
like image 56
Daniel Fekete Avatar answered Dec 07 '25 22:12

Daniel Fekete



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!