title: Create spinner without <Spinner in xml
body: <p>I was using a spinner in a TableRow and it was working perfectly well except that I didn't like spinner icon is stretching out according to the selected item. I tried to delete Spinner section in xml and create it on my code.  </p>
  
  <p>To create a spinner in OnCreate():</p>
  
  <pre><code>selectArea = /*(Spinner)this.findViewById(R.id.spinner);*/new Spinner(this);
  
  String[] ss = getResources().getStringArray(R.array.countries);
  ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, ss);
  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinner.setAdapter(adapter);
  
  selectArea.setOnItemSelectedListener(new MyOnItemSelectedListener());
  selectArea.setSelection(prefInt);
  </code></pre>
  
  <p>To handle a selection event:</p>
  
  <pre><code>public class MyOnItemSelectedListener implements OnItemSelectedListener {
      public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int pos, long id) {
          Log.d(TAG, "onItemSelected() " + id);
      }
  
      public void onNothingSelected(AdapterView&lt;?&gt; parent) {
          // Do nothing.
      }
  }
  </code></pre>
  
  <p>It worked almost perfect. TableRow show no spinner icon, on touching TableRow, it pops up items to be selected. My only problem is that, on selecting one tiem, I never get my onItemSelected() called..<br>
  What could be wrong?</p>