Question

I want to perform different action on Click and DoubleClick event on TextView.

I am trying it with below code :

tvcurrentlocation.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Toast.makeText(getApplicationContext(), "google map started", Toast.LENGTH_SHORT).show();
        }
    });

    @SuppressWarnings("deprecation")
    final GestureDetector gestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {
        public boolean onDoubleTap(final MotionEvent e) {
            Toast.makeText(getApplicationContext(), "inside doubletap", Toast.LENGTH_SHORT).show();
            Log.e("", "Open new activty here");
            return true;
        }
    });


    tvcurrentlocation.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
        }
    });

Please Help!!!
Regards,
Sourabh

Was it helpful?

Solution

I think you should use Long Press event rather than DoubleClick. Its a stander click event for android device. You can see an answer here on SO.

But if you have decide to use a double click in you app then you can get a help on this Link1, Link2

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top