title: how to set selection on spinner based on ID, not index or position
body: <p>I have spinner, that containing value and ID , such as below :</p>
  
  <pre><code>ID      message
  ---     ----
  100     Elephant
  120     Lion
  125     Cat
  153     Dog
  165     Bear
  </code></pre>
  
  <p>this is the way for showing only value on my spinner :</p>
  
  <pre><code>    public class Message {
  private Int id;
  private String message;
  public Int getId() {
      return id;
  }
  public void setId(Int id) {
      this.id = id;
  }
  public String getMessage() {
      return message;
  }
  public void setMessage(String message) {
      this.message = message;
  }
  
   @Override
   public String toString() {          
       return  message;
   }
  </code></pre>
  
  <p>this is how I passing Message into my adapter :</p>
  
  <pre><code> protected List&lt;Message&gt; messages = null;
  ArrayAdapter &lt;Message&gt; arrayadapter = new ArrayAdapter&lt;Message&gt;( activity,android.R.layout.simple_spinner_item,messages);               
                      arrayadapter.setDropDownViewResource(R.layout.textview);
  </code></pre>
  
  <p>spinner1.setAdapter(arrayadapter); </p>
  
  <p>this is how i get ID  from selected spinner :</p>
  
  <pre><code>    spinner1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
          public void onItemSelected(AdapterView&lt;?&gt; parent, View view,
                  int pos, long id) {
              Message mSelected = (Message) parent.getItemAtPosition(pos);
              Log.i("Id:", mSelected.getId());
  
          }
  }
  </code></pre>
  
  <p>the problem is when I tried to set my spinner based on ID such as <code>ID: 165</code>, not from value or index, I tried to this method :</p>
  
  <pre><code>ArrayAdapter myAdap = (ArrayAdapter) spinner1.getAdapter();
          int spinnerPosition = myAdap.getPosition(message.getID());
          spinner1.setSelection(Message.getID());
  </code></pre>
  
  <p>but it return error, so my question, how to set selection on spinner based on their ID?</p>