Reputation: 7433
According to Android Developers:
onLongPress
Notified when a long press occurs with the initial on down MotionEvent that trigged it.
onShowPress
The user has performed a down MotionEvent and not performed a move or up yet. This event is commonly used to provide visual feedback to the user to let them know that their action has been recognized i.e. highlight an element.
I tried both with a button and used a Toast
to indicate that showPress
and longPress
happened. However, I don't see any difference.
What's the difference between onLongPress
and onShowPress
? What are some examples when we override
GestureDetector
for those MotionEvents
?
Upvotes: 1
Views: 1255
Reputation: 7433
onLongPress
will be triggered the moment the amount of time a touch event (pressing the screen) is equal to getLongPressTimeout
(can be seen here). When it triggers, this shows that a press has turnt to a long press.
onShowPress
, on the other hand, indicates that a touch event is indeed a tap (not a scroll). To know when a touch event is a tap, there is a time interval in which movement from the touch event will be registered. The time interval is returned by getTapTimeout
(read here).
Both are related to touch events, but have different time of trigger (and different purposes). Reading the link provided by the comment in the question (here) will help you in understanding both.
Upvotes: 4