title: Populating Spinner using a HashMap?
body: <p>I am trying to populate a spinner using items from a custom class I created via a simple adapter, containing a HashMap. My app keeps crashing when I use <code>setSimpleAdapter()</code>, so I commented it out. But when I use <code>spinner1.setAdapter(dataAdapter)</code>, it shows no items on the spinner. Here's my code:</p>
  
  <p>This is in my <code>onCreate()</code>:</p>
  
  <pre><code>spinner1 = (Spinner) findViewById(R.id.spinner1);
  
          ArrayAdapter &lt;CharSequence&gt; dataAdapter =
                  new ArrayAdapter &lt;CharSequence&gt; (this, android.R.layout.simple_spinner_item );
          dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  
          spinner1.setAdapter(dataAdapter);
  
          //setSimpleAdapter();
  
          // Spinner item selection Listener
          addListenerOnSpinnerItemSelection();
  
          // Button click Listener
          addListenerOnButton();
  
  // Add spinner data
  public void addListenerOnSpinnerItemSelection(){
  
      spinner1.setOnItemSelectedListener(new CustomOnItemSelectedListener());
  }
  
  //get the selected dropdown list value
  public void addListenerOnButton() {
  
      spinner1 = (Spinner) findViewById(R.id.spinner1);
  
      btnSubmit = (Button) findViewById(R.id.btnSubmit);
  
      btnSubmit.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
  
              final AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
              alertDialog.setTitle("X");
              alertDialog.setMessage("" + String.valueOf(spinner1.getSelectedItem()));
              alertDialog.setButton("Close", new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                      //Dismisses alert
                      alertDialog.dismiss();
                  }
              });
  
              alertDialog.show();
  
          }
  
      });
  
  }
  </code></pre>
  
  <p>Can anyone point me in the right direction? I have been googling for like an hour now. Any help will be appreciated.</p>