title: Android refresh actionbar and title on fragment change
body: <p>in my app i am developing an activity using the actionbar in <code>NAVIGATION_MODE_TABS</code>-mode.
  Each tab is showing a fragment (list, detail).
  Initially the list-tab is visibile.
  The list is implementing <code>setMultiChoicheModeListener()</code> and modifies the <code>ActionBar</code> and the title of the activity if one or more items are selected.
  How can i reset the title and the <code>ActionBar</code> to the inital value (title and actions) when the user clicks on the detail-tab without deselecting the items?</p>
  
  <p>BTW Target-Platform is > 4.1 and i am not using the support library.</p>
  
  <p>Thanks.</p>
  
  <pre><code>public class MyActivity extends Activity {
  
      @Override
      protected void onCreate (Bundle savedInstanceState) {
          this.actionBar = getActionBar();
          this.actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
          ....
          for (Tab tab : getTabs())
          {
             //here are two tabs added (List and Detail)
             this.actionBar.addTab(tab);
          }
          ....
      }
  
      protected class NavigationTabListener implements ActionBar.TabListener {
  
          private Fragment fragment;
          ....
          public void onTabSelected(Tab tab, FragmentTransaction ft) {
             ft.replace(newFragmentResourceId, this.fragment);
          }
      }
  }
  
  public class MyListViewFragment extends LinearLayout implements IListViewFragment {
  
       ....
  
       @Override
       public void initialize() {
           inflate(getContext(), listLayoutResourceId, this); 
           this.myList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
           this.myList.setMultiChoiceModeListener(new MultiChoiceModeListener() {
  
          ....
  
          @Override
          public boolean onCreateActionMode(ActionMode mode, Menu menu)
          {
              MenuInflater inflater = mode.getMenuInflater();
              inflater.inflate(selectedItemsMenuResourceId, menu);
  
              return true;
          }
  
          public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked)
          {
              if (checked)
              {
                  this.numberItemsSelected++;
                  adapter.setNewSelection(position);
              }
              else
              {
                  this.numberItemsSelected--;
                  adapter.removeSelection(position);
              }
  
              mode.setTitle(getContext().getResources().getQuantityString(
                  R.plurals.items_selected, this.numberItemsSelected,
                  Integer.valueOf(this.numberItemsSelected)));
  
           }
  
           ....
  
       }
  }
  </code></pre>
  
  <p>I am trying to implement the MVP pattern, but it's still in evaluation phase. The Activity acts as the presenter, the views are in separate classes. </p>
  
  <p>For each Fragment i am also implementing the MVP apttern, but i think this is not interesting to solve the problem.</p>
  
  <p>Some notes to the classes:</p>
  
  <p><code>MyActivity</code> creates two fragments (one for List, one for Detail view, the detail view has nothing to do with the selected items).
  The initial view of the activity is the fragment with the list.
  If the user selects some entries I am updating the action bar and the title through the callback of <code>MultiChoiceModeListener</code>. 
  But the user can now change the fragment by clicking on the "Detail" tab without deselecting the items or clicking to the new elements in the action bar, the result is that the detail fragment is shown, but the title of the activity is still the one I modified in the <code>MultiChoiceModeListener</code>, and there is also the check mark of the action bar visible (auto created by the system).
  So the best way is I think to get somehow the current <code>ActionMode</code>, so I can invoke finish() to "reset" the <code>ActionBar</code> and the title.</p>