title: Enable button on MainActivity based on spinner OnItemSelectedListener
body: <p>I'm very new to android development and this is basically my first app.</p>
  
  <p>I followed the guide on developer.android.com and other souces on the internet to work with spinners.</p>
  
  <p>On my main activity, I have a spinner and a button and what I would like to do is to Enable (setClickable) the button based on the spinner selected item.</p>
  
  <pre><code>public class MainMenu extends Activity {    
  
  private Spinner spinner1;   
  
  @Override
  public void onCreate(Bundle savedInstanceState) {       
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main_menu);              
  
      //Add items to spinner 1 dynamically
      addItemsOnSpinner1();    
      addListenertoSpinner();        
  }          
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.activity_main_menu, menu);
      return true;
  }
  
  public void addItemsOnSpinner1(){
      spinner1 = (Spinner) findViewById(R.id.spinner1);
      List&lt;String&gt; list = new ArrayList&lt;String&gt;();
      list.add("Test 1");
      list.add("Test 2");
      list.add("Add new");
      ArrayAdapter&lt;String&gt; dataAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item,list);
      dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
      spinner1.setAdapter(dataAdapter);       
  }
  
  public void addListenertoSpinner(){
      spinner1 = (Spinner) findViewById(R.id.spinner1);
      spinner1.setOnItemSelectedListener(new CustomOnItemSelectedListener());    
  }           
  
  }
  </code></pre>
  
  <p>I have successfully created an OnItemSelectedListener class from which I can display the spinner selected item text:</p>
  
  <pre><code>public class CustomOnItemSelectedListener extends Activity implements OnItemSelectedListener {
  
  public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int pos, long id) {
      // TODO Auto-generated method stub              
      if(parent.getItemAtPosition(pos).toString()== "Add new"){
          Toast.makeText(parent.getContext(), 
                  "OnItemSelectedListener : " + parent.getItemAtPosition(pos).toString(),
                  Toast.LENGTH_SHORT).show();         
      }
  
  }
  
  public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
      // TODO Auto-generated method stub
  
  }
  }
  </code></pre>
  
  <p>My question is:</p>
  
  <p>How can I set the Button.setClickable? 
  I tried doing something like:</p>
  
  <pre><code>if(parent.getItemAtPosition(pos).toString()== "Add new"){
          Button b1 = (Button)findViewById(R.id.button1);
          b1.setClickable(true);                                  
      }
  </code></pre>
  
  <p>but the application crashes...</p>
  
  <p>Cheers in advance!</p>