title: Spinner in RecyclerView to update item values
body: <p>How can I update the values in my Dataset from a <code>Spinner</code> selection in a <code>RecyclerView</code>? Should I be using <code>LiveData</code> and Room with <code>notifyItemChange()</code>, data binding, or something simpler? I have a <code>Horse</code>class and a <code>HorseData</code> class. The number of items is static and the options for the variables are static. I do not need to add values or items, I just need to be able to select the variable <code>WinPercentHorse</code> for each item and have that value saved back to the dataset. </p>
  
  <pre><code>public class HorseAdapter extends RecyclerView.Adapter&lt;HorseViewHolder&gt;  {
  
  private AdapterView.OnItemSelectedListener onItemSelectedListener;
  
      //we are storing all the horses in a list
      private List&lt;Horse&gt; horseList;
  
      //this context we will use to inflate the layout
      private Context mCtx;
  
  
      //getting the context and product list with constructor
      public HorseAdapter(Context mCtx, List&lt;Horse&gt; horseList) {
          this.mCtx = mCtx;
          this.horseList = horseList;
      }
  
      @Override
      public HorseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          //inflating and returning our view holder
          LayoutInflater inflater = LayoutInflater.from(mCtx);
          View view = inflater.inflate(R.layout.item_layout, null);
          return new HorseViewHolder(view);
      }
  
      @Override
      public void onBindViewHolder(final HorseViewHolder holder, final int position) {
          //getting the product of the specified position
          Horse horse = horseList.get(position);
  
          //binding the data with the viewholder views
          holder.ViewWinPercent.setText(String.valueOf(horse.getWinPercentHorse()));
          holder.imageView.setImageDrawable(mCtx.getResources().getDrawable(horse.getImgHorse()));
          holder.ViewValueLine.setText(String.valueOf(horse.getValueOdds()));
          holder.itemView.setTag(horse.getId());
          holder.spinnerView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
              @Override
              public void onItemSelected(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
                  // Update winPercent of item On selecting a spinner item
                  Toast.makeText(mCtx, "Spinner Selection =" + l + "item selected =" + position, Toast.LENGTH_SHORT).show();
  
                  //How to update the WinPercentHorse variable for this item in the horseList
                  //Then refresh the item notifyItemChange(position, object payload)?
              }
  
              @Override
              public void onNothingSelected(AdapterView&lt;?&gt; adapterView) {
  
              }
          });
      }
  
      @Override
      public int getItemCount() {
          return horseList.size();
      }
  
      public void setHorseList(List&lt;Horse&gt; horseList) {
          this.horseList = horseList;
          notifyDataSetChanged();
      }
  
  }
  
  class HorseViewHolder extends RecyclerView.ViewHolder  {
  
  TextView ViewWinPercent, ViewValueLine;
      ImageView imageView;
      Spinner spinnerView;
  
  
      public HorseViewHolder(View itemView) {
          super(itemView);
  
          ViewWinPercent = itemView.findViewById(R.id.winPercentHorse);
          ViewValueLine = itemView.findViewById(R.id.valueLine);
          imageView = itemView.findViewById(R.id.imgHorse);
          spinnerView=itemView.findViewById(R.id.spinner);
  
      }
  
  }
  </code></pre>