0

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?

Community
  • 1
  • 1
hoacin
  • 340
  • 1
  • 2
  • 19
  • `OnPlayerInfoRatingGenericMotion` which interface callback function? I did not find it in `IOnGenericMotionListener`. – Mike Ma Dec 22 '16 at 06:59
  • imageViewPlayerInfoRating.GenericMotion+=OnPlayerRatingGenericMotion. This way it is created. – hoacin Dec 22 '16 at 07:51

1 Answers1

1

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.

Mike Ma
  • 2,017
  • 1
  • 12
  • 17
  • Thank you for an answer, it helped me a lot! I only moved those 3 ifs from OnTouchEvent to OnTouch. Only there things work for me. – hoacin Dec 22 '16 at 15:11