title: Android: Change actionbar icon after click and change it back after onCreate()
body: <p>I try to change the icon of the action bar to a progress bar in <code>onOptionsItemSelected(MenuItem)</code> method.</p>
  
  <pre><code>    public boolean onOptionsItemSelected(MenuItem item) {
      switch (item.getItemId()) {
      case android.R.id.home:
          NavUtils.navigateUpFromSameTask(this);
          return true;
      case R.id.progressitem2:
          mProgress = item;
          mProgressCreate = mProgress;
          mProgress.setActionView(R.layout.progress);
          mLayout.removeView(mTable);
          // Execute code that change mTable again.
          return true;
      }
  </code></pre>
  
  <p>progress.xml file:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:addStatesFromChildren="true"
                android:focusable="true"
                android:paddingLeft="4dp"
                android:paddingRight="4dp"
                android:gravity="center" &gt;
      &lt;ProgressBar
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:focusable="true"
              style="@android:style/Widget.ProgressBar.Small"/&gt;
  
  &lt;/LinearLayout&gt; 
  </code></pre>
  
  <p>The action bar is created in this way:</p>
  
  <pre><code>@Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.actionbar, menu);
      mProgress = menu.getItem(0);
      mProgressCreate = mProgress;
      return true;
  }
  </code></pre>
  
  <p>action_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/progressitem2" 
              android:icon="@drawable/ic_action_refresh"
              android:title="Reload"
              android:showAsAction="ifRoom|withText"
              android:visible="true" /&gt;
  &lt;/menu&gt;
  </code></pre>
  
  <p>This works good. The progress icon is shown after I click the action bar icon.</p>
  
  <p>I try to keep the reference of the original action bar symbol in <code>mProgressCreate</code> and try to add the action view back at the end of the <code>onCreate()</code> method:</p>
  
  <pre><code>mProgress.setActionView(mProgressCreate.getActionView());
  </code></pre>
  
  <p>But this do not work...</p>
  
  <p>What`s wrong here?</p>
  
  <p>Regards,
  Sandro</p>