title: Android Spinner - How to default list selection to none
body: <p>I have an Android form that needs to update itself based on certain selections. The form is currently made up of 2 Spinners (A and B). Spinner B not created until Spinner A's selection is made. After the selection is made B will be displayed to the view and it's contents dynamically filled based on A's selection. Here is my code:</p>
  
  <pre><code>public class MyForm extends Activity 
  {   
      private final int SEL_ACTIVATE = 0;
      private final int SEL_DEACTIVATE = 1;
  
      private static final String[] actionList = {"Activate", "Deactivate" };
  
      @Override
      public void onCreate(Bundle savedInstanceState) 
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          table = (TableLayout) findViewById(R.id.table);
  
          showListA(table);
      }
  
      public void showListA(View v)
      {        
          rowAction = new TableRow(this);
  
          Spinner spinner = new Spinner(this);
          spinner.setPrompt("Select...");
          spinner.setOnItemSelectedListener(
              new OnItemSelectedListener() 
              {
                  public void onItemSelected(AdapterView&lt;?&gt; parent, View v, int position, long id) 
                  {
                      switch (position)
                      {
                      case SEL_ACTIVATE:
                      case SEL_DEACTIVATE:
                          showListB(v);
                          break;
                      }
                  }
  
                  public void onNothingSelected(AdapterView&lt;?&gt; arg0) 
                  {
                      // TODO Auto-generated method stub
                  }
          });
  
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt; (this, android.R.layout.simple_spinner_item, actionList);
          adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
          spinner.setAdapter(adapter);
  
          rowAction.addView(tvAction);
          rowAction.addView(spinner);
  
          table.addView(rowAction, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      }
  
      ...
  }
  </code></pre>
  
  <p>This code works correctly. When either "Activate" or "Deactivate" are selected from the list, <code>showListB()</code> executes which is very similar to <code>showListA()</code> in how it creates a new row which contains Label and Spinner.</p>
  
  <p>The problem is that, by default, "Activate" is shown in the Spinner which executes <code>showListB()</code> and right off the bat, the second part of the form is created based on the "Activate" option. The only workaround that I can come up with is to add a third field to the Spinner like so:</p>
  
  <pre><code>private static final String[] actionList = {"None", "Activate", "Deactivate" };
  
  ...
  
  switch (position)
  {
  case SEL_NONE:
      break;
  case SEL_ACTIVATE:
  case SEL_DEACTIVATE:
      showListB(v);
      break;
  }
  </code></pre>
  
  <p>This works... but I don't want a third option in the list. I just want it to, by default, be blank or show some sort of 'prompt' text that is not an option in the list once it is pressed. Is this possible?</p>
  
  <p>Thanks</p>
  
  <p>EDIT:</p>
  
  <p>xml content:</p>
  
  <pre><code>&lt;Spinner
      android:id="@+id/spinnerAction"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"/&gt;  
  </code></pre>