title: using notifyItemRemoved or notifyDataSetChanged with RecyclerView in Android
body: <p>I am creating a list of cards to display using the RecyclerView, where each card has a button to remove that card from the list.</p>
  
  <p>When i use <strong>notifyItemRemoved()</strong> to remove the card in the RecyclerView, it removes the item and animates fine but the data in the list is not updated correctly. </p>
  
  <p>If instead of that, i switch to the <strong>notifyDataSetChanged()</strong> then the items in list are removed and updated correctly, but then the cards dont animate.</p>
  
  <p>Does someone has any experience in using the notifyItemRemoved() and know why it behaves differently than notifyDataSetChanged?</p>
  
  <p>Here is some peiece of code that i am using:</p>
  
  <pre><code>private List&lt;DetectedIssue&gt; issues = new ArrayList&lt;DetectedIssue&gt;();
  
  @Override
  public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
      // - get element from your dataset at this position
      // - replace the contents of the view with that element
      if(position &gt;0){
          RiskViewHolder riskHolder = (RiskViewHolder)holder;
          final int index = position - 1;
          final DetectedIssue anIssue = issues.get(index);
  
          riskHolder.button.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  try {
                      int index = issues.indexOf(anIssue);
                      issues.remove(anIssue);
                      notifyItemRemoved(index);
  
                      //notifyDataSetChanged();
                  } catch (SQLException e) {
                      e.printStackTrace();
                  }
              }
          });
      }
  }
  
  @Override
  public int getItemCount() {
      return (issues.size()+1);
  }
  </code></pre>