title: Android - show button after swiping recyclerview item
body: <p>I have created <code>RecyclerView</code> which contains <code>CardView</code> in order to show data. I would like to implement <code>iOS</code> style of swiping list elements to show action buttons.
  My method which should allow me to show icon after swiping left an <code>RecyclerView</code> item:</p>
  
  <pre><code>public void initializeListeners() {
          ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
  
              @Override
              public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
                  return false;
              }
  
              @Override
              public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
                  int position = viewHolder.getAdapterPosition();
  
                  if (direction == ItemTouchHelper.LEFT) {
                      Toast.makeText(getView().getContext(),"LEFT",Toast.LENGTH_LONG).show();
                  }
              }
  
              @Override
              public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
  
                  Bitmap icon;
                  if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
  
                      View itemView = viewHolder.itemView;
                      float height = (float) itemView.getBottom() - (float) itemView.getTop();
                      float width = height / 3;
  
                     if (dX &lt; 0) {
                          p.setColor(Color.parseColor("#D32F2F"));
                          RectF background = new RectF((float) itemView.getRight() + dX/4, (float) itemView.getTop(), (float) itemView.getRight(), (float) itemView.getBottom());
                          c.drawRect(background, p);
                          icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_delete_black_24dp);
                          RectF icon_dest = new RectF((float) itemView.getRight() - 2 * width, (float) itemView.getTop() + width, (float) itemView.getRight() - width, (float) itemView.getBottom() - width);
                          c.drawBitmap(icon, null, icon_dest, p);
  
                      }
                  }
                  super.onChildDraw(c, recyclerView, viewHolder, dX/4, dY, actionState, isCurrentlyActive);
              }
          };
          ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
          itemTouchHelper.attachToRecyclerView(binding.myPlans);
  
      }
  </code></pre>
  
  <p>effect of this is:
  <a href="https://i.stack.imgur.com/Ooh0e.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Ooh0e.png" alt="enter image description here"></a></p>
  
  <p>I would like to make this icon <code>clickable</code> in order to send <code>HTTP</code> request using <code>id</code> of object of clicked possition in <code>RecyclerView</code> (after alertview confirmation)</p>
  
  <p>is it possible? I was trying to replace <code>Bitmap</code> for <code>ImageButton</code> with no success</p>