@Override
 public void initForMenu(Context context, MenuBuilder menu) {
   // Clear the expanded action view when menus change.
   if (mMenu != null && mCurrentExpandedItem != null) {
     mMenu.collapseItemActionView(mCurrentExpandedItem);
   }
   mMenu = menu;
 }
  public void clear() {
    if (mExpandedItem != null) {
      collapseItemActionView(mExpandedItem);
    }
    mItems.clear();

    onItemsChanged(true);
  }
 public boolean collapseActionView()
 {
     if ((mShowAsAction & 8) != 0)
     {
         if (mActionView == null)
         {
             return true;
         }
         if (mOnActionExpandListener == null || mOnActionExpandListener.onMenuItemActionCollapse(this))
         {
             return mMenu.collapseItemActionView(this);
         }
     }
     return false;
 }
  @Override
  public boolean collapseActionView() {
    if ((mShowAsAction & SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW) == 0) {
      return false;
    }
    if (mActionView == null) {
      // We're already collapsed if we have no action view.
      return true;
    }

    if (mOnActionExpandListener == null || mOnActionExpandListener.onMenuItemActionCollapse(this)) {
      return mMenu.collapseItemActionView(this);
    }

    return false;
  }