public bool OnTouch(View v, MotionEvent e) { float x = e.GetX(); float y = e.GetY(); // Do something with the touch coordinates... return true; }
public bool OnTouchEvent(MotionEvent e) { if (e.Action == MotionEventActions.Down) { // User touched the screen } else if (e.Action == MotionEventActions.Move) { // User is moving their finger on the screen } else if (e.Action == MotionEventActions.Up) { // User lifted their finger from the screen } return true; }This example shows how to detect different types of touch events using the `MotionEventActions` enumeration. The `OnTouchEvent()` method is called when a touch event occurs, and the `Action` property of the `MotionEvent` object is used to determine the type of action that occurred. These examples are part of the `Android.Views` namespace in C#.