title: Spinner is not working in android
body: <p>Spinner is not working. Here is my code:</p>
  
  <pre><code>public class second extends Activity{   
      Spinner spin;
      String[] str;
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.second);        
          spin = (Spinner) findViewById(R.id.spin);
          str = new String[] {"bike","car"};      
          spin.setAdapter(new ArrayAdapter&lt;CharSequence&gt;(this, android.R.layout.simple_dropdown_item_1line, str));    
  
          spin.setOnItemClickListener(new OnItemClickListener() {
  
              public void onItemClick(AdapterView&lt;?&gt; adapter, View view, int pos,
                  long id) {
              // TODO Auto-generated method stub
  
              String data= spin.getItemAtPosition(pos).toString();
              Toast.makeText(second.this, data, Toast.LENGTH_SHORT).show();
                 }    
          });
      }
  }
  </code></pre>