[mono-android] Touch events in view

Matthew Leibowitz mattleibowmail at gmail.com
Thu Jun 21 11:09:12 UTC 2012


This code should not compile as the OnTouchEvent method needs a return
value. Try returning the value from base.OnTouchEvent . What you need to
return is, I think, false for the down to tell the window that you have not
processed the down event. This allows the event to continue to the Up event.
On Jun 21, 2012 10:13 AM, "Hänke, Maik" <haenke at initions.com> wrote:

> Hi,****
>
> ** **
>
> I try to get touch events in my view but only the MotionEventActions.Down
> appears. There are no Up and Down events.****
>
> ** **
>
> I tried override OnTouchEvent in my activity and it works. What is wrong
> in my view?****
>
> ** **
>
> public class TestView : View****
>
> {****
>
>        public TestView(Context c)****
>
>              : base(c)****
>
>        {****
>
>        }****
>
> ** **
>
>        public override bool OnTouchEvent(MotionEvent e)****
>
>        {****
>
>               base.OnTouchEvent(e);****
>
>                     ****
>
>               switch (e.Action)****
>
>               {****
>
>                      case MotionEventActions.Down:****
>
>                            Log.Debug("Test", "DOWN");****
>
>                            break;****
>
>                      case MotionEventActions.Up:****
>
>                            Log.Debug("Test", "UP");****
>
>                            break;****
>
>                      case MotionEventActions.Move:****
>
>                            Log.Debug("Test", "MOVE");****
>
>                            break;****
>
>               }****
>
>        }****
>
> }****
>
> ** **
>
> [Activity(Label = "TouchTest", MainLauncher = true)]****
>
> public class Activity1 : Activity****
>
> {****
>
>        protected override void OnCreate(Bundle bundle)****
>
>        {****
>
>              base.OnCreate(bundle);****
>
> ** **
>
>              SetContentView(new TestView(this));****
>
>        }****
>
> }****
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
> ** **
>
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monodroid/attachments/20120621/1bc85235/attachment-0001.html>


More information about the Monodroid mailing list