title: RecyclerView row onClick and child button onClick
body: <p>I am using the method from <a href="https://stackoverflow.com/questions/24471109/recyclerview-onclick">RecyclerView onClick</a> to perform on item click method in recyclerview. But the problem is <strong>how to handle child button in the recyclerview</strong>? I have perform onclick method in the adapter but still not work, It always perform recyclerview onitemclicklistener first then only perform onclick method from adapter. How to handle it properly?</p>
  
  <pre><code>import android.content.Context;
  import android.support.v7.widget.RecyclerView;
  import android.view.GestureDetector;
  import android.view.MotionEvent;
  import android.view.View;
  
  
  public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener {
    private OnItemClickListener mListener;
  
    public interface OnItemClickListener {
      public void onItemClick(View view, int position);
  
      public void onLongItemClick(View view, int position);
    }
  
    GestureDetector mGestureDetector;
  
    public RecyclerItemClickListener(Context context, final RecyclerView recyclerView, OnItemClickListener listener) {
      mListener = listener;
      mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
          @Override
          public boolean onSingleTapUp(MotionEvent e) {
              return true;
          }
  
          @Override
          public void onLongPress(MotionEvent e) {
              View child = recyclerView.findChildViewUnder(e.getX(), e.getY());
              if (child != null &amp;&amp; mListener != null) {
                  mListener.onLongItemClick(child, recyclerView.getChildAdapterPosition(child));
              }
          }
      });
  }
  
    @Override public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) {
      View childView = view.findChildViewUnder(e.getX(), e.getY());
      if (childView != null &amp;&amp; mListener != null &amp;&amp; mGestureDetector.onTouchEvent(e)) {
        mListener.onItemClick(childView, view.getChildAdapterPosition(childView));
        return true;
      }
      return false;
    }
  
    @Override public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) { }
  
    @Override
    public void onRequestDisallowInterceptTouchEvent (boolean disallowIntercept){}
  }
  </code></pre>