title: How to set and get the id for the items in the spinner in Android
body: <p>I have a problem like I had a Spinner containing the Names of all developers working in the Company.<br>
  I have used the <code>ArrayAdapter</code> with a Array having the names of all the <strong>developers</strong> which is fetched from the database.  </p>
  
  <p>The problem is that when I update the Name Of Developer field, I get Only the Name of the Developer which is not enough to update the data as their can be multiple developers with the same name in the Company.<br>
  So now I require the id of the developers to update it..<br>
  How to store that <strong>id</strong> of the developers with the <code>Spinner</code> so that I can achieve this.  </p>
  
  <p>For example, I want to do like is as that we do in <code>HTML</code>::<br>
  <code>
      &lt;select&gt;<br>
      &lt;option id="1"&gt;Developer1&lt;/option&gt;<br>
      &lt;option id="2"&gt;Developer2&lt;/option&gt;<br>
      &lt;option id="3"&gt;Developer2&lt;/option&gt;<br>
      &lt;option id="4"&gt;Developer2&lt;/option&gt;<br>
      &lt;/select&gt;</code>   </p>
  
  <p>where the <strong>id</strong> attached would be the database <strong>id</strong>.<br>
  I want to imitate this in android.  </p>
  
  <p>This the code that I have used to store the names in the array::  </p>
  
  <pre><code>String alldevelopers = null;
  try 
  {
    ArrayList&lt;NameValuePair&gt; postP = new ArrayList&lt;NameValuePair&gt;();
    alldevelopers = CustomHttpClient.executeHttpPost("/fetchdevelopers.php", postP);
    String respcl = alldevelopers.toString();
    alldevelopersParser dev = new alldevelopersParser();
    ow = dev.parseByDOM(respcl);
  } 
  catch (Exception e) {
     e.printStackTrace();
  }  
  
  String developers[] = new String[ow.length];    //dev is a class object  
  for (int n = 0; n &lt; ow.length; n++)   
  {  
    developers[n] = ow.developer[n][2];
  }  
  </code></pre>
  
  <p>This is the Spinner that would spin the array..  </p>
  
  <pre><code>final Spinner devl = (Spinner) findViewById(R.id.towner);  
  devl.setOnItemSelectedListener(managetasks.this);
  ArrayAdapter&lt;String&gt; b =   
  new ArrayAdapter&lt;String&gt;getApplicationContext(),  
  android.R.layout.simple_spinner_item,developers);  
  b.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);  
  devl.setAdapter(b);
  </code></pre>