如何在Android上的EditText实现的DoubleClick?如何在、Android、DoubleClick、EditText

2023-09-07 16:22:36 作者:╃ヌо昌fυ夸

我有一个活动1里面有一个的EditText。我想打开另一个活动活性2当上了的EditText用户双击。

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

推荐答案

使用这样的:

final GestureDetector gestureDetector = new GestureDetector(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);
    }
});