title: How to change menu overflow button programmatically?
body: <p>So I have a overflow menu button in the view which I have converted into an edit button. Here is the XML code for the button:</p>
  
  <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      tools:context=".HomeActivity"&gt;
      &lt;item android:id="@+id/action_edit"
          android:title="Edit"
          android:icon="@drawable/editbutton"
          app:showAsAction="always"/&gt;
  &lt;/menu&gt;
  </code></pre>
  
  <p>I have also created a java function on edit button pressed as below:</p>
  
  <pre><code>public boolean onOptionsItemSelected(MenuItem item) {
      switch (item.getItemId()) {
          case R.id.action_edit:
              floatIn.start();
              fabImageButton.setTranslationX(-1 * fabOffset);
              populateAnimators();
              openAnimSet.start();
              return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>What I want to do is when the edit button is pressed, inside the case statement within the onOptionsItemSelected is to change the drawable of the menu button (from an edit drawable to a close drawable) and then change a property so that if the button is pressed again when the new drawable is showing, a different set of java code is triggered. I was thinking to programattically change the ID and then add another case statement? This needs to be then converted back to the original button when the close edit button is pressed.</p>
  
  <p>Thanks</p>
  
  <p>Kabeer</p>