On Apr 10, 2012, at 2:07 PM, King Coffee wrote: > I'm trying to convert an android java example code snippet to a C# code > snippet. The java snippet uses Enums like: MotionEvent.ACTION_MASK and > MotionEvent.ACTION_DOWN.
Those were moved to the Android.Views.MotionEventActions enumeration, which is also the type of the MotionEvent.Action property. Within MonoDevelop (and presumably Visual Studio) if you do: eve.Action == the IDE will suggest MotionEventActions values. (Not sure why MonoDevelop doesn't suggest those values when using `&`...) > So, how and I fix the code snippet below: > > public override bool OnTouchEvent(MotionEvent eve) > { > base.OnTouchEvent(eve); > > int action = eve.Action & MotionEvent.ACTION_MASK; var action = e.Action & MotionEventActions.Mask; // or: var action = e.ActionMasked; switch (action) { case MotionEventActions.Down: ... case MotionEventActions.Move: ... } > I defined a generic image GestureListener of the form: > > public class MyImageListener You don't list any base classes, yet... > public override bool OnTouchEvent(MotionEvent eve) you're overriding a method? I'm not sure how that works. ;-) One thing to keep in mind: when implementing Android interfaces, in particular when implementing IJavaObject, DO NOT IMPLEMENT IJavaObject! Subclass Java.Lang.Object instead: http://docs.monodroid.net/index.aspx?link=T:Android.Runtime.IJavaObject http://docs.xamarin.com/android/advanced_topics/architecture/android_callable_wrappers Failure to do so will result in weird runtime errors, frequently resembling NullPointerExceptions (assuming the common approach of making IJavaObject.Handle return IntPtr.Zero...). - Jon _______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid