GenericMotion - Action Down not firing

868 views Asked by At

I want to trace the whole movement of a finger that started by touching my ImageView. I found that GenericMotion event should be the correct one to use.

What am I supposed to do (or to avoid) to get Actions Down, Move and Up in GenericMotion event? I get only HoverEnter, HoverMove and HoverExit actions, even if I start with touching the center of my ImageView.

Android: OnTouch, MotionEvent.ACTION_MOVE is not recognized?

Here I learned that without handling Down action I can't get the remaining actions, but I don't get the Down action!

private void OnPlayerInfoRatingGenericMotion(object sender, View.GenericMotionEventArgs e)
{
    //goes here only with hover actions
    if (e.Event.Action==MotionEventActions.Down)
    {
        //never goes here
    }
    if (e.Event.Action==MotionEventActions.Move)
    {
        //never goes here
    }
}

What am I doing wrong?

1

There are 1 answers

1
Mike Ma On BEST ANSWER

GenericMotion can not detect the gesture of your finger. I think it is only used to report for movement event. You can refer to the document here.

For example , You can move your imageview from top to bottom then the GenericMotion can detect the "move" action.

If you want to detect your finger event I think you can achieve OnTouchListener.

For example:

imgview.SetOnTouchListener(new MyTouchListener());

achieve MyTouchListener:

public class MyTouchListener: Java.Lang.Object, View.IOnTouchListener
{
    public bool OnTouch(View v, MotionEvent e)
    {
        throw new NotImplementedException();
    }

    public bool OnTouchEvent(View v, MotionEvent e)
    {
        if (e.Action == MotionEventActions.Down)
        {
            Log.Debug("Mike", "Down");
            Console.WriteLine("Down");
            return true;
        }
        if (e.Action == MotionEventActions.Up)
        {
            Log.Debug("Mike", "Up");
            Console.WriteLine("Up");
            return true;
        }
        if (e.Action == MotionEventActions.Move)
        {
            Log.Debug("Mike", "Move");
            Console.WriteLine("Move");
            return true;
        }

        return false;
    }
}

Also you can achieve IOnGestureListener to detect your gesture.