title: Using SimpleAdapter with Spinner
body: <p>I am new to Android development. I am trying to populate a spinner by using the SimpleAdapter. But spinner's list is showing blank element. When I click any element, its text is shown properly in Toast. Please tell me what is the problem in my code below.</p>
  
  <pre><code> public void onCreate(Bundle savedInstanceState) {
  
    private List&lt;Map&lt;String, String&gt;&gt; data = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
  
    String[] from = new String[] { "colorsData" };
    int[] to = new int[] { R.id.spinner };
  
    String[] colors = getResources().getStringArray(R.array.colorsData);
  
    for (int i = 0; i &lt; colors.length; i++) {
     data.add(addData(colors[i]));
    }
  
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
  
    SimpleAdapter simpleAdapter = new SimpleAdapter(this, data, android.R.layout.simple_spinner_item, from, to);
    simpleAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(simpleAdapter);
  
    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
     @Override
     public void onItemSelected(AdapterView&lt;?&gt; parent, View view,
       int position, long id) {
      Toast.makeText(
        parent.getContext(),
        "Selected Color:-  "
          + parent.getItemAtPosition(position),
        Toast.LENGTH_LONG).show();
     }
    });
   }
  
   private Map&lt;String, String&gt; addData(String colorName) {
    Map&lt;String, String&gt; mapList = new HashMap&lt;String, String&gt;();
    mapList.put("colorsData", colorName);
    return mapList;
   }
  </code></pre>