Как реализовать DoubleClick на Android EditText? - PullRequest
2 голосов
/ 20 октября 2011

У меня есть «Activity1», которая имеет «EditText».Я хочу открыть другое действие «Activity2», когда пользователь дважды щелкает «EditText».

1 Ответ

9 голосов
/ 20 октября 2011

Используйте это:

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);
    }
});
...