title: Using databinding to highlight selected recyclerview row
body: <p>I'm trying to highlight a row of my recyclerview when a user clicks on it. </p>
  
  <p>Recyclerview row layout:</p>
  
  <pre><code>&lt;data&gt;
      &lt;variable name="model" type="ItemRow" /&gt;
      &lt;variable name="listener" type="ItemClickListener" /&gt;
  &lt;/data&gt;
  
  &lt;com.google.android.material.card.MaterialCardView       
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"&gt;
  
      &lt;TextView            
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@{model.name}"
          android:onClick="@{() -&gt; listener.onItemClicked(model)}"           
          android:background="@{model.isSelected ? @drawable/white : @drawable/blue}"/&gt;
  
  &lt;/com.google.android.material.card.MaterialCardView&gt;
  </code></pre>
  
  <p>The onClickListener is instantiated in the activity:</p>
  
  <pre><code>ItemClickListener listener = item -&gt; viewModel.selectItem(item);
  </code></pre>
  
  <p>The viewmodel sets the isSelected property of Item to true:</p>
  
  <pre><code>public void selectItem(Item item)
  {
      item.setSelected(true);        
  }
  </code></pre>
  
  <p>However, this doesn't change the row's background. Debugging through the code shows me that the item's isSelected property is set to true. Is there something I'm missing?</p>