Frank Cheng
Frank Cheng

Reputation: 6186

How to distinguish Click event from touch event in onTouchEvent method when app is running in device?

I override the onTouchEvent method of Activty. In this method i would like to listen to actions: touch and click and give them two different reactions. The problem is when i test my app in emulator, everything works fine. But not in device. As in device, when i just click a button, i don't just get ACTION_DOWN and ACTION_UP but a few ACTION_MOVE signals after ACTION_DOWN.

Upvotes: 1

Views: 441

Answers (1)

Paul Nikonowicz
Paul Nikonowicz

Reputation: 3903

Instead of overriding the TouchEvent on your Activity, assign a listener to the Button itself.

View view = getViewById(R.id.entire_view);
view.setOnTouchListener( ...

Upvotes: 1

Related Questions