Xamarin.Android. Setting time for LongClick event

时间:2016-08-31 18:27:07

标签: c# android events xamarin xamarin.android

Is it possible in Xamarin.Android to set event LongClick click time or something similar? The click time as it is, is too short for me.

1 个答案:

答案 0 :(得分:2)

LongClick timing is managed by the Android OS, so it cannot be directly modified. However, you could go around the problem by handling everything by yourself.

  1. Create a touch listener.
  2. In the OnTouch event, detect if the touch action is MotionEventActions.Down and get the current time in milliseconds by using CurrentTimeMillis method.
  3. Have another check for MotionEventActions.Up to detect when the user lifts the finger. Calculate the time difference between touch up and touch down events and if it's long enough, do something.

Here's some code samples related to touch events. It shows how to create the touch listener and react to touch events.