2

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

Yaqub Ahmad
  • 27,569
  • 23
  • 102
  • 149

1 Answers1

11

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);
    }
});
rookieDeveloper
  • 2,459
  • 1
  • 22
  • 44
Daniel Fekete
  • 4,988
  • 3
  • 23
  • 23
  • Thanks Daniel! "new OnTouchListener()" was not working i replaced it with "new View.OnTouchListener()" – Yaqub Ahmad Oct 21 '11 at 06:12
  • 1
    To fix Deprecation issue replace with final GestureDetector gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() { – Andrew Rokicki Sep 08 '14 at 13:18