title: How to swipe RecyclerView Item when I click Button..?
body: <p>I have multiple items in recyclerView and each item has one cross button. I want to remove that item when I click on Cross button. I am able to swipe that item but want to implement it on Button Click.</p>
  
  <p>My Adapter Is </p>
  
  <pre><code>public class RecyclerListAdapter extends RecyclerView.Adapter&lt;ItemViewHolder&gt; implements ItemTouchHelperAdapter {
  
  private static final String[] STRINGS = new String[]{
          "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"
  };
  
  private final List&lt;String&gt; mItems = new ArrayList&lt;&gt;();
  private Context context;
  private ItemTouchHelper.Callback callback;
  
  
  public RecyclerListAdapter(Activity activity, ItemTouchHelper.Callback callback) {
      mItems.addAll(Arrays.asList(STRINGS));
      this.context = activity;
      this.callback = callback;
  }
  
  @Override
  public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main, parent, false);
      return new ItemViewHolder(view);
  }
  
  @Override
  public void onBindViewHolder(final ItemViewHolder holder, final int position) {
      holder.textView.setText(mItems.get(position));
      holder.ivCancel.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
          // Swipe item from here
          }
      });
  }
  
  @Override
  public int getItemCount() {
      return mItems.size();
  }
  
  @Override
  public void onItemMove(int fromPosition, int toPosition) {
      if (fromPosition &lt; toPosition) {
          for (int i = fromPosition; i &lt; toPosition; i++) {
              Collections.swap(mItems, i, i + 1);
          }
      } else {
          for (int i = fromPosition; i &gt; toPosition; i--) {
              Collections.swap(mItems, i, i - 1);
          }
      }
      notifyItemMoved(fromPosition, toPosition);
  }
  
  @Override
  public void onItemDismiss(int position) {
      mItems.remove(position);
      notifyItemRemoved(position);
  }
  </code></pre>
  
  <p>My CallBack is </p>
  
  <pre><code>public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback {
  
  private final ItemTouchHelperAdapter mAdapter;
  
  public SimpleItemTouchHelperCallback(ItemTouchHelperAdapter adapter) {
      mAdapter = adapter;
  }
  
  @Override
  public boolean isLongPressDragEnabled() {
      return false;
  }
  
  @Override
  public boolean isItemViewSwipeEnabled() {
      return true;
  }
  
  @Override
  public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
      int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
      int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
      return makeMovementFlags(dragFlags, swipeFlags);
  }
  
  @Override
  public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
                        RecyclerView.ViewHolder target) {
      mAdapter.onItemMove(viewHolder.getAdapterPosition(), target.getAdapterPosition());
      return true;
  }
  
  @Override
  public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
      mAdapter.onItemDismiss(viewHolder.getAdapterPosition());
  }
  </code></pre>
  
  <p>My Activity is </p>
  
  <pre><code>public class MainFragment extends Activity {
  
  public ItemTouchHelper.Callback callback;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Activity activity = MainFragment.this;
      RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
      recyclerView.setHasFixedSize(true);
      recyclerView.setLayoutManager(new LinearLayoutManager(activity));
  
  
      RecyclerListAdapter adapter = new RecyclerListAdapter(activity,callback);
      recyclerView.setAdapter(adapter);
  
  
      callback = new SimpleItemTouchHelperCallback(adapter);
  
  
      ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
      touchHelper.attachToRecyclerView(recyclerView);
  
  
  }
  </code></pre>
  
  <p>Please guide me..</p>