@Override
 public void setEmbeddedTabView(ScrollingTabContainerView tabView) {
   if (mTabView != null && mTabView.getParent() == mToolbar) {
     mToolbar.removeView(mTabView);
   }
   mTabView = tabView;
   if (tabView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
     mToolbar.addView(mTabView, 0);
     Toolbar.LayoutParams lp = (Toolbar.LayoutParams) mTabView.getLayoutParams();
     lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
     lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
     lp.gravity = Gravity.START | Gravity.BOTTOM;
     tabView.setAllowCollapse(true);
   }
 }
  @Override
  public void setNavigationMode(int mode) {
    final int oldMode = mNavigationMode;
    if (mode != oldMode) {
      switch (oldMode) {
        case ActionBar.NAVIGATION_MODE_LIST:
          if (mSpinner != null && mSpinner.getParent() == mToolbar) {
            mToolbar.removeView(mSpinner);
          }
          break;
        case ActionBar.NAVIGATION_MODE_TABS:
          if (mTabView != null && mTabView.getParent() == mToolbar) {
            mToolbar.removeView(mTabView);
          }
          break;
      }

      mNavigationMode = mode;

      switch (mode) {
        case ActionBar.NAVIGATION_MODE_STANDARD:
          break;
        case ActionBar.NAVIGATION_MODE_LIST:
          ensureSpinner();
          mToolbar.addView(mSpinner, 0);
          break;
        case ActionBar.NAVIGATION_MODE_TABS:
          if (mTabView != null) {
            mToolbar.addView(mTabView, 0);
            Toolbar.LayoutParams lp = (Toolbar.LayoutParams) mTabView.getLayoutParams();
            lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
            lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
            lp.gravity = Gravity.START | Gravity.BOTTOM;
          }
          break;
        default:
          throw new IllegalArgumentException("Invalid navigation mode " + mode);
      }
    }
  }