xx----------MainActivity.cs------------------xx using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; using System.Collections.Generic; namespace ListViewSwipeItem { [Activity(Label = "My Activity")] public class MyScheduleActivity : Activity, View.IOnTouchListener { UserDetails noterep = new UserDetails(); List item = new List(); GestureDetector _gestureDetector; GestureListener _gestureListener; private LinearLayout _myButton; private float _viewX; ListView listView; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.NoteEditor); _gestureListener = new GestureListener(); _gestureListener.SwipeLeftEvent += GestureLeft; _gestureListener.SwipeRightEvent += GestureRight; _gestureDetector = new GestureDetector(this, _gestureListener); item = noterep.GetAllNotes(); listView = FindViewById(Resource.Id.arrayList); listView.Adapter = new NoteAdapter(this, Resource.Layout.NoteListRow, item); //listView.ItemClick += HandleItemClick; } private void HandleItemClick(object sender, AdapterView.ItemClickEventArgs e) { //int position = (int)e.Id; //var view = listView.GetChildAt(position); //_myButton = view.FindViewById(Resource.Id.myView); //_myButton.SetOnTouchListener(this); //_myButton.Layout(136, _myButton.Top, 706, _myButton.Bottom); //_gestureListener = new GestureListener(); //_gestureListener.SwipeLeftEvent += GestureLeft; //_gestureListener.SwipeRightEvent += GestureRight; // _gestureDetector = new GestureDetector(this, _gestureListener); //Toast.MakeText(this, "You Clickeked " + item[position].Name, ToastLength.Long).Show(); } void GestureLeft(MotionEvent first, MotionEvent second) { int position = listView.PointToPosition((int)second.GetX(), (int)second.GetY()); var view = listView.GetChildAt(position); var name = view.FindViewById(Resource.Id.spacename).Text; _myButton = view.FindViewById(Resource.Id.myView); _myButton.Layout(136, _myButton.Top, 706, _myButton.Bottom); //Toast.MakeText(this, "You swipe left on the " + name + position, ToastLength.Long).Show(); //Toast.MakeText(this, "You swipe left on the " + first.GetX() + " " + first.GetY() + " " + second.GetX() + " " + second.GetY(), ToastLength.Long).Show(); _myButton.SetOnTouchListener(this); } void GestureRight(MotionEvent first, MotionEvent second) { //int position = listView.PointToPosition((int)second.GetX(), (int)second.GetY()); //var view = listView.GetChildAt(position); //_myButton = view.FindViewById(Resource.Id.myView); //_myButton.Layout(606, _myButton.Top, 1174, _myButton.Bottom); //Toast.MakeText(this, "You swipe right on the " + item[position].Name, ToastLength.Long).Show(); } public override bool DispatchTouchEvent(MotionEvent ev) { _gestureDetector.OnTouchEvent(ev); return base.DispatchTouchEvent(ev); } string formatMotionEventAttributes(MotionEvent first, MotionEvent second) { return "First MotionEvent[ x= " + first.GetX().ToString() + ", y= " + first.GetY().ToString() + "] Second MotionEvent[ x= " + second.GetX().ToString() + ", y= " + second.GetY().ToString() + "]"; } public bool OnTouch(View v, MotionEvent e) { switch (e.Action) { case MotionEventActions.Down: _viewX = e.GetX(); break; case MotionEventActions.Move: var left = (int)(e.RawX - _viewX); var right = (left + v.Width); v.Layout(left, v.Top, right, v.Bottom); Toast.MakeText(this, "You swipe right on the " + _viewX, ToastLength.Long).Show(); break; } return true; } } } //Main.axml------------------------------------------------- //NoteListRow.axml-------------------------------------------