title: How to change menu item text dynamically in Android
body: <p>I'm trying to change the title of a menu item from outside of the <code>onOptionsItemSelected(MenuItem item)</code> method.</p>
  
  <p>I already do the following;</p>
  
  <pre><code>public boolean onOptionsItemSelected(MenuItem item) {
    try {
      switch(item.getItemId()) {
        case R.id.bedSwitch:
          if(item.getTitle().equals("Set to 'In bed'")) {
            item.setTitle("Set to 'Out of bed'");
            inBed = false;
          } else {
            item.setTitle("Set to 'In bed'");
            inBed = true;
          }
          break;
      }
    } catch(Exception e) {
      Log.i("Sleep Recorder", e.toString());
    }
    return true;
  }
  </code></pre>
  
  <p>however I'd like to be able to modify the title of a particular menu item outside of this method.</p>