title: Xamarin Android: How to swipe left recyclerview items
body: <p>Hello everyone my name is Taniguchi:</p>
  
  <p>I have a recyclerview and i wish to swipe to Delete in xamarin android but i only find articles in java</p>
  
  <p>does anyone knows how to do it in C# ?</p>
  
  <p>The java article teaching how to swipe to delete.</p>
  
  <p><a href="https://medium.com/@zackcosborn/step-by-step-recyclerview-swipe-to-delete-and-undo-7bbae1fce27e" rel="nofollow noreferrer">https://medium.com/@zackcosborn/step-by-step-recyclerview-swipe-to-delete-and-undo-7bbae1fce27e</a></p>
  
  <p>my recylerview adapter:</p>
  
  <pre><code>public class RecyclerAdapter : RecyclerView.Adapter, View.IOnClickListener, View.IOnLongClickListener
  {
      private View view;
      private Boolean isSelected = false;
  
      public Boolean IsSelected()
      {
          return isSelected;
      }
  
      public void setSelected(Boolean selected)
      {
  
          isSelected = selected;
      }
  
      public static RecyclerView.Adapter mAdapter;
      public static bool isActionMode = true;
      private int viewType;
      private ViewGroup parent;
      public static bool unselect = false;
      private Activity mActivity;
      private MyActionMode mActionMode;
      private RecyclerView.ViewHolder holder;
      private List&lt;time_entry&gt; mTime_Entries;
      private Context context;
      private View p;
      private ActionMode mode;
      public static bool count = false;
      public static int CountAuxiliar = 0;
      private MyActionMode myActionMode;
  
      public event EventHandler&lt;int&gt; ItemClick;
      public RecyclerAdapter(List&lt;time_entry&gt; time_entries, Context context)
      {
          mTime_Entries = time_entries;
          this.context = context;
      }
  
      public RecyclerAdapter(List&lt;time_entry&gt; time_entries, Activity activity)
      {
          mTime_Entries = time_entries;
          mActivity = activity;
      }
  
      public RecyclerAdapter(List&lt;time_entry&gt; time_entries, MyActionMode myActionMode)
      {
          mTime_Entries = time_entries;
          this.myActionMode = myActionMode;
      }
  
      public class MyView : RecyclerView.ViewHolder
      {
          public View mMainView {get; set;}
          public TextView mName {get; set;}
          public TextView mSubject {get; set;}
          public TextView mMessage {get; set;}
  
          public MyView(View view) : base(view)
          {
              mMainView = view;
          }
  
      }
  
  
      public  override int ItemCount
      {
          get { return mTime_Entries.Count; }
      }
  
      public  override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
      {
          LayoutInflater inflater = LayoutInflater.From(parent.Context);
          View row = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.row, parent, false);
          RecyclerViewHolder vh = new RecyclerViewHolder(row);
          return vh;
      }
  
      public  override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
      {
  
          RecyclerViewHolder myHolder = holder as RecyclerViewHolder;
          myHolder.cbx.Visibility = mTime_Entries[position].IsSelected() ? ViewStates.Visible : ViewStates.Gone;
          myHolder.cbx.Checked = mTime_Entries[position].IsSelected();
  
  
          myHolder.mProject_Task.Text = mTime_Entries[position].projectTask;
          myHolder.mDate.Text = mTime_Entries[position].date;
          myHolder.mDescription.Text = mTime_Entries[position].description;
  
  
          myHolder.ItemView.SetBackgroundColor(mTime_Entries[position].IsSelected() ? Color.LightBlue : Color.Transparent);
          myHolder.ItemView.Tag = position;
          myHolder.ItemView.SetOnClickListener(this);
          myHolder.ItemView.SetOnLongClickListener(this);
  
      }
  
      void View.IOnClickListener.OnClick(View v)
      {
          if (CountAuxiliar &gt; 0)
          {
              int position = (int)v.Tag;
              mTime_Entries[position].setSelected(!mTime_Entries[position].IsSelected());
              v.SetBackgroundColor(mTime_Entries[position].IsSelected() ? Color.LightBlue : Color.Transparent);
              v.FindViewById(Resource.Id.checkBox1).Visibility = mTime_Entries[position].IsSelected() ? ViewStates.Visible : ViewStates.Invisible;
              if (mTime_Entries[position].IsSelected())
              {
                  CountAuxiliar++;
              }
              else
              {
                  CountAuxiliar--;
              }
              //mode.Title = CountAuxiliar.ToString() + " " + "Selecionados";
              MainActivity.title.Text = CountAuxiliar.ToString() + " " + "Selecionados";
              Toast.MakeText(v.Context, "Click : " + CountAuxiliar + "---" + position, ToastLength.Short).Show();
          }
          if (CountAuxiliar &lt; 1 &amp;&amp; count == true)
          {
              count = false;
              MainActivity.toolbar2.Visibility = ViewStates.Gone;
              MainActivity.bottomnavigationview1.Visibility = ViewStates.Gone;
              MainActivity.floatinactionbutton1.Visibility = ViewStates.Visible;
          }
      }
      public void removeSelection()
      {
          if (mTime_Entries != null)
          {
              foreach (time_entry email in mTime_Entries)
              {
                  email.setSelected(false);
  
              }
          }
         NotifyDataSetChanged();
          CountAuxiliar = 0;
          count = false;
          MainActivity.bottomnavigationview1.Visibility = ViewStates.Gone;
          MainActivity.floatinactionbutton1.Visibility = ViewStates.Visible;
  
      }
  
      public void checkall()
      {
          if (mTime_Entries != null)
          {
              foreach (time_entry email in mTime_Entries)
              {
                  email.setSelected(true);
  
              }
          }
          NotifyDataSetChanged();
          MainActivity.bottomnavigationview1.Visibility = ViewStates.Visible;
      }
  
  
      public bool OnLongClick(View v)
      {
  
          if (CountAuxiliar &lt; 1)
          {
              CountAuxiliar = 1;
              count = true;
              int position = (int)v.Tag;
              mTime_Entries[position].setSelected(!mTime_Entries[position].IsSelected());
              v.SetBackgroundColor(mTime_Entries[position].IsSelected() ? Color.LightBlue : Color.Transparent);
              MainActivity.bottomnavigationview1.Visibility = ViewStates.Visible;
              MainActivity.floatinactionbutton1.Visibility = ViewStates.Gone;
              v.FindViewById(Resource.Id.checkBox1).Visibility = mTime_Entries[position].IsSelected() ? ViewStates.Visible : ViewStates.Invisible;
              MainActivity.title.Text = CountAuxiliar.ToString() + " " + "Selecionado";
  
              MainActivity.toolbar2.Visibility = ViewStates.Visible;
              count = true;
  
              Toast.MakeText(v.Context, "Long Click : " + mTime_Entries[position].IsSelected() + "---" + position, ToastLength.Short).Show();
          }
          return true;
      }
  }
  </code></pre>