title: How can I pass object to the spinner in android?
body: <p>The code is:</p>
  
  <pre><code>public class Organization {
  
  private String name;
  private Long id;
  
  public Organization(){
  }
  
  public Organization(String name, Long id) {
      super();
      this.name = name;
      this.id = id;
  }
  
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  
  public Long getId() {
      return id;
  }
  
  public void setId(Long id) {
      this.id = id;
  }
  }
  </code></pre>
  
  <p>The spinner is:</p>
  
  <pre><code> Spinner sp = (Spinner) navigationView.getMenu().findItem(R.id.brand_spinner).getActionView();
   sp.setAdapter(new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_spinner_dropdown_item,contactList));
   sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
  
              String value = parent.getItemAtPosition(position).toString();
              Toast.makeText(parent.getContext(),""+value+"",Toast.LENGTH_SHORT).show();
          }
   });
  </code></pre>
  
  <p>How can I pass both name and id to the spinner and the should be listed in the spinner, by selecting the name in the spinner. Store the id of the name in the local variable.</p>