How to implement DoubleClick on Android EditText?

一个人想着一个人 提交于 2019-11-30 19:27:25

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/7837601/how-to-implement-doubleclick-on-android-edittext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!