title: Updating multiple spinners
body: <p>I have a <code>listView</code> containing some <code>Spinner</code>s. I want to update the <code>Spinner</code>s when I select an item. For example:</p>
  
  <ul>
  <li>Spinner 1 : <code>{A, B, C}</code></li>
  <li>Spinner 2 : <code>{1, 2, 3, 4, 5}</code></li>
  <li>Spinner 3 : <code>{a, b, c, d, e, f, g, h}</code></li>
  </ul>
  
  <p>If I select A, I want to have:</p>
  
  <ul>
  <li>Spinner 1 : <code>{A, B, C}</code></li>
  <li>Spinner 2 : <code>{1, 2}</code></li>
  <li>Spinner 3 : <code>{d, e, f, g, h}</code></li>
  </ul>
  
  <p>And if I select 1 :</p>
  
  <ul>
  <li>Spinner 1 : <code>{A, B, C}</code></li>
  <li>Spinner 2 : <code>{1, 2}</code></li>
  <li>Spinner 3 : <code>{d, e, f}</code></li>
  </ul>
  
  <p>I guess I have to update the adapters, but I'm a bit confused about the <code>getView()</code> method and how to update the adapters.</p>
  
  <p>I know how to have the good list, my problem is that the data don't update when I want (it's not shown).</p>
  
  <pre><code>public class CustomSpinnerAdapter extends BaseAdapter {
  
      private Context context;
      private ArrayList&lt;Critere&gt; navDrawerItems;
      private int pos;
      public HashMap&lt;String, String&gt; criteres_modif;
      private ArrayList&lt;String&gt; list;
      private ArrayAdapter&lt;String&gt; dataAdapter;
      private ArrayList&lt;Spinner&gt; spinnerList;
  
      public CustomSpinnerAdapter(Context context,
              ArrayList&lt;Critere&gt; navDrawerItems) {
          this.context = context;
          this.navDrawerItems = navDrawerItems;
          criteres_modif = new HashMap&lt;String, String&gt;();
          spinnerList = new ArrayList&lt;Spinner&gt;();
      }
  
      @Override
      public int getCount() {
          // TODO Auto-generated method stub
          return navDrawerItems.size();
      }
  
      @Override
      public Object getItem(int position) {
          // TODO Auto-generated method stub
          return navDrawerItems.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          // TODO Auto-generated method stub
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          if (convertView == null) {
              LayoutInflater mInflater = (LayoutInflater) context
                      .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
              convertView = mInflater.inflate(R.layout.drawer_list_item, null);
              TextView tv = (TextView) convertView.findViewById(R.id.drawerTitle);
              if (tv != null) {
                  tv.setText(navDrawerItems.get(position).getLabel());
                  spinnerList.add((Spinner) convertView
                          .findViewById(R.id.drawerSpinner));
                  DatabaseHelper db = new DatabaseHelper(Catalogue.activity);
                  list = db.getCritereDistinct(navDrawerItems.get(position)
                          .getTableCritere(), criteres_modif);
                  dataAdapter = new ArrayAdapter&lt;String&gt;(Catalogue.activity,
                          R.layout.item_single_text, list);
                  spinnerList.get(position).setAdapter(dataAdapter);
                  pos = position;
                  spinnerList.get(position).setOnItemSelectedListener(
                          new OnItemSelectedListener() {
                              @Override
                              public void onItemSelected(AdapterView&lt;?&gt; arg0,
                                      View arg1, int arg2, long arg3) {
                                  if (arg2 != 0) {
  
                                      Log.w("Bad pos","pos : " + pos); // Always 0, it must be between 0 and 5 depending on the spinner selected
                                      if (!criteres_modif
                                              .containsKey(navDrawerItems
                                                      .get(pos).getTableCritere())) {
                                          criteres_modif.put(
                                                  navDrawerItems.get(pos)
                                                          .getTableCritere(),
                                                  navDrawerItems.get(pos)
                                                          .getList().get(arg2));
                                          Log.w("Key not exist", "Clé : "
                                                  + navDrawerItems.get(pos)
                                                          .getTableCritere()
                                                  + " Val : "
                                                  + navDrawerItems.get(pos)
                                                          .getList().get(arg2));
                                      } else {
                                          criteres_modif.remove(navDrawerItems
                                                  .get(pos).getTableCritere());
                                          criteres_modif.put(
                                                  navDrawerItems.get(pos)
                                                          .getTableCritere(),
                                                  navDrawerItems.get(pos)
                                                          .getList().get(arg2));
                                          Log.w("Key exists", "Clé : "
                                                  + navDrawerItems.get(pos)
                                                          .getTableCritere()
                                                  + " Val : "
                                                  + navDrawerItems.get(pos)
                                                          .getList().get(arg2));
                                      }
                                      updateNavSpinners(pos);
                                  }
                              }
  
                              @Override
                              public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
                                  // TODO Auto-generated method stub
                              }
                          });
              }
          }
          return convertView;
      }
  
      public void updateNavSpinners(int position) {
          DatabaseHelper db = new DatabaseHelper(Catalogue.activity);
          for (int i = 0; i &lt; navDrawerItems.size(); i++) {
              if (position != i) {
                  navDrawerItems.get(i).setList(
                          db.getCritereDistinct(navDrawerItems.get(i)
                                  .getTableCritere(), criteres_modif));
                  ((BaseAdapter) spinnerList.get(i).getAdapter())
                          .notifyDataSetChanged();
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>EDIT :</strong> I updated my code. I'm getting the correct data at the beginning but when I click on an item it doesn't update the others spinners even if the data seems to be the one I need in the log. Moreover, I am getting problems to get the correct spinner selected. I have a variable called "pos" which is supposed to be the position of my spinner in my listView but its value is always 0.</p>
  
  <p>Thank you in advance for any help you can give me.</p>