title: Enable/Disable ActionBar Menu Item
body: <p>I have actionbar menuitems cancel and save.</p>
  
  <p>menu.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt;
      &lt;item android:id="@+id/saveButton" 
            android:showAsAction="always"          
            android:title="@string/save" 
            android:visible="true"&gt;
  
      &lt;/item&gt;
      &lt;item android:id="@+id/cancelButton" 
            android:showAsAction="always"         
            android:title="@string/cancel" 
            android:visible="true"&gt;        
      &lt;/item&gt;
  
  &lt;/menu&gt;
  </code></pre>
  
  <p>I want to disable save menuitem when activity is started.</p>
  
  <p>My activity code -</p>
  
  <pre><code>@Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.add_project);
  
          EditText projectName = (EditText) findViewById(R.id.editTextProjectName);   
          projectName.addTextChangedListener(new TextWatcher() {
  
              @Override
              public void onTextChanged(CharSequence s, int start, int before, int count) {
                  configureSaveButton(s);             
              }           
              @Override
              public void beforeTextChanged(CharSequence s, int start, int count,int after) {}
              @Override
              public void afterTextChanged(Editable s) {}
          });
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          MenuInflater inflater = getMenuInflater();
          inflater.inflate(R.menu.addprojectmenu, menu);      
          return super.onCreateOptionsMenu(menu);
      }
  
      @Override
      public boolean onPrepareOptionsMenu(Menu menu) {
          MenuItem item = (MenuItem) findViewById(R.id.saveButton);
          item.setEnabled(false);     
          return super.onPrepareOptionsMenu(menu);
      }
  
      private void configureSaveButton(CharSequence s){
          String text = null;
          if(s != null){
              text = s.toString();
          }       
          if(text != null &amp;&amp; text.trim().length() != 0){
  
          }else{
  
          }
      }
  </code></pre>
  
  <p>So what I am trying to do here is, initially when activity is started save menu item should be disabled and when editext contains some text then it should be enabled. </p>
  
  <p>I am not sure what should be the code in if else in configureSaveButton method.
  Also how can i disable save menu item initially.</p>
  
  <p>I get null pointer exception in onPrepareOptionsMenu.</p>
  
  <p>I am using android 4.1</p>