[mono-android] Touch events in view

Hänke, Maik haenke at initions.com
Thu Jun 21 09:12:35 UTC 2012


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));

       }

}

 

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monodroid/attachments/20120621/fd176ef7/attachment.html>


More information about the Monodroid mailing list