Don't know if this will help I picked it up ages ago from Stack Overflow - I think it was Java originall but it seems to work Only trouble is if you have some objects on screen then swiping across then doesnt work - I probably need to make the gesture listener more sophisticated.
So put in your own gesture listener class thus public class GestureListener : Java.Lang.Object, GestureDetector.IOnGestureListener { private readonly View view; private Context cntxt; private TabHost TH; private EditText dpf; private static int SWIPE_MAX_OFF_PATH = 270; private static int SWIPE_MIN_DISTANCE = 50; private static int SWIPE_THRESHOLD_VELOCITY = 30; public GestureListener(View view, Context Cntxt, int currtab, TabHost th,EditText dpfield) { this.view = view; this.cntxt = Cntxt; this.TH = th; this.dpf = dpfield; } //public IntPtr Handle // public IntPtr Handle // { // get { throw new NotImplementedException(); } // } public bool OnDown(MotionEvent e) { // Toast.MakeText(cntxt, "down swipe", ToastLength.Short).Show(); // view.Text = "- DOWN -"; return true; } public bool OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { if (System.Math.Abs(e1.GetY() - e2.GetY()) > SWIPE_MAX_OFF_PATH) return false; // right to left swipe if (e1.GetX() - e2.GetX() > SWIPE_MIN_DISTANCE && System.Math.Abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { // Toast.MakeText(view.Context, "Left Swipe", ToastLength.Short).Show(); if (TH.CurrentTab == 3) { TH.SetCurrentTabByTag("pax"); return true; } if (TH.CurrentTab == 4) { TH.CurrentTab = 0; } else { TH.CurrentTab = TH.CurrentTab + 1; dpf.Selected = true; } return true; //TabHost.CurrentTab=1; } else if (e2.GetX() - e1.GetX() > SWIPE_MIN_DISTANCE && System.Math.Abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) //Toast.MakeText(view.Context, "Right Swipe", ToastLength.Short).Show(); if (TH.CurrentTab == 0) { TH.CurrentTab = 4; } else { TH.CurrentTab = TH.CurrentTab - 1; dpf.Selected = true; } } catch (System.Exception e) { Toast.MakeText(view.Context, "" + e.ToString(), ToastLength.Long).Show(); // nothing } return false; } public void OnLongPress(MotionEvent e) { // Toast.MakeText(cntxt, "Long press", ToastLength.Short).Show(); //view.Text = "- LONG PRESS -"; } public bool OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { // Toast.MakeText(cntxt, "this si a fling or scroll", ToastLength.Short).Show(); //view.Text = "- FLING -"; return true; } public void OnShowPress(MotionEvent e) { // Toast.MakeText(cntxt, "a show pres?", ToastLength.Short).Show(); //view.Text = "- SHOW PRESS -"; } public bool OnSingleTapUp(MotionEvent e) { //view.Text = "- SINGLE TAP UP -"; // Toast.MakeText(cntxt, "single up tap", ToastLength.Short).Show(); return true; } } //=======================end of gesture listener stuff Then put an instance of Gesture detector and listener - In my app these are at the top of Activity1 private GestureDetector gestureScannerA; private GestureListener gestureListenerA; Instatiate them in your oncreate gestureListenerA = new GestureListener(TabHost, this, 0, this.TabHost, this.depfield); gestureScannerA = new GestureDetector(this, gestureListenerA); Now you need to override the OnTouch event - put this code in after your oncreate method public override bool OnTouchEvent(MotionEvent e) { try { return gestureScannerA.OnTouchEvent(e); } catch (System.Exception eee) { Toast.MakeText(this, "Error \n" + eee.Message, ToastLength.Long).Show(); return gestureScannerA.OnTouchEvent(e); } } ================ And that should be it - though I've almost certainly forgotten something Be interested for any comments on how one deals with a swipe across other objects on the view All the best John Murray -----Original Message----- From: monodroid-boun...@lists.ximian.com [mailto:monodroid-boun...@lists.ximian.com] On Behalf Of EricW Sent: 01 October 2012 9:15 PM To: monodroid@lists.ximian.com Subject: [mono-android] how to add swipe? Hi, I building an app with two activities. The first one is for login. After login the second activity is started. On this activity I have 3 tablelayouts in a ViewFlipper. On the first tablelayout the user can do a search. On the other layouts the results are shown. I would like the user to be able to switch layouts by swiping. I have read many forums, blogs and articles, but I can't get anything to work. I need a good example in C# that will work in MonoDevelop. Please help. rg, Eric -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/how-to-add-swipe-tp5712038.htm l Sent from the Mono for Android mailing list archive at Nabble.com. _______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid _______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid