title: Android Spinners in ListView, do I have to use a ViewHolder?
body: <p>I have an issue with <code>Spinners</code> in a <code>ListView</code>. I have a <code>ListView</code> with a <code>CheckBox</code>, a label, and two <code>Spinners</code>. The <code>Spinner</code> are populated from SQLite and that is working fine. I am not using the <code>ViewHolder</code> method because so far when the <code>ListView</code> row is clicked the <code>CheckBoxes</code> are checked or unchecked and the change is immediately saved to the database. When the row is checked the <code>Spinners</code> are made visible but are not visible when the row is not checked.</p>
  
  <p>So the issue that I haven't managed to find a solution for is that I have no idea how to get the actual <code>Spinner</code> or even get the <code>ListItem</code> row that the clicked <code>Spinner</code> is on. The <code>Activity</code> extends <code>ListActivity</code>. Anyone know a way I can do this without using a <code>ViewHolder</code> or do I have to use a <code>ViewHolder</code>?</p>
  
  <p>Here is the code that declares and populates the <code>ListView</code>:</p>
  
  <pre><code>mSsCursor = mDbHelper.fetchAllSsPlaylistSs(mPlId);
          startManagingCursor(mSsCursor);
  
          String[] from = new String[]{"pl_selected", BTDbAdapter.KEY_NAME, BTDbAdapter.KEY_NAME2};
  
          int[] to = new int[]{R.id.pl_selected, R.id.name, R.id.name2};
  
          mAllSs = new SimpleCursorAdapter(this, R.layout.pl_edit_ss_row, mSsCursor, from, to);
          mAllSs.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
          //custom handling of setting the value
          public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
              if(columnIndex == 3) {
                      ViewGroup row = (ViewGroup)view.getParent().getParent();
                      mSId = cursor.getInt(0);
                      if (cursor.getInt(3) &gt; 0) {
                          mCheckBox = (CheckBox) row.findViewById(R.id.pl_selected);
                          mCheckBox.setChecked(true);
                          mTSpin = (Spinner) row.findViewById(R.id.pl_t_spin);
                          mMSpin = (Spinner) row.findViewById(R.id.pl_m_spin);
                          mtvT = (TextView) row.findViewById(R.id.pl_t);
                          mtvM = (TextView) row.findViewById(R.id.pl_m);
                          mTSpin.setVisibility(View.VISIBLE);
                          mtvT.setVisibility(View.VISIBLE);
                          mMSpin.setVisibility(View.VISIBLE);
                          mtvM.setVisibility(View.VISIBLE);
                          //set the values in the t spinner
                          PopulateTSpinner(cursor.getInt(4));
                          //set the values in the m spinner
                          PopulateMSpinner(cursor.getInt(5));
                      }
                      else {
                          mCheckBox = (CheckBox) row.findViewById(R.id.pl_selected);
                          mCheckBox.setChecked(false);
                          mTSpin = (Spinner) row.findViewById(R.id.pl_t_spin);
                          mMSpin = (Spinner) row.findViewById(R.id.pl_m_spin);
                          mtvT = (TextView) row.findViewById(R.id.pl_t);
                          mtvM = (TextView) row.findViewById(R.id.pl_m);
                          mTSpin.setVisibility(View.GONE);
                          mtvT.setVisibility(View.GONE);
                          mMSpin.setVisibility(View.GONE);
                          mtvM.setVisibility(View.GONE);
                      }                   
                      return true;
              }
              return false;
          }
      });
      setListAdapter(mAllSs);
  </code></pre>
  
  <p>Thanks.</p>