示例#1
0
    @Override
    public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) {
      mExpandedActionView = item.getActionView();
      mExpandedHomeLayout.setIcon(mIcon.getConstantState().newDrawable(/* TODO getResources() */ ));
      mCurrentExpandedItem = item;
      if (mExpandedActionView.getParent() != ActionBarView.this) {
        addView(mExpandedActionView);
      }
      if (mExpandedHomeLayout.getParent() != ActionBarView.this) {
        addView(mExpandedHomeLayout);
      }
      mHomeLayout.setVisibility(GONE);
      if (mTitleLayout != null) mTitleLayout.setVisibility(GONE);
      if (mTabScrollView != null) mTabScrollView.setVisibility(GONE);
      if (mSpinner != null) mSpinner.setVisibility(GONE);
      if (mCustomNavView != null) mCustomNavView.setVisibility(GONE);
      requestLayout();
      item.setActionViewExpanded(true);

      if (mExpandedActionView instanceof CollapsibleActionView) {
        ((CollapsibleActionView) mExpandedActionView).onActionViewExpanded();
      }

      return true;
    }
  @Override
  public View getItemView(MenuItemImpl item, View convertView, ViewGroup parent) {
    View actionView = item.getActionView();
    if (actionView == null || item.hasCollapsibleActionView()) {
      if (!(convertView instanceof ActionMenuItemView)) {
        convertView = null;
      }
      actionView = super.getItemView(item, convertView, parent);
    }
    actionView.setVisibility(item.isActionViewExpanded() ? View.GONE : View.VISIBLE);

    final ActionMenuView menuParent = (ActionMenuView) parent;
    final ViewGroup.LayoutParams lp = actionView.getLayoutParams();
    if (!menuParent.checkLayoutParams(lp)) {
      actionView.setLayoutParams(menuParent.generateLayoutParams(lp));
    }
    return actionView;
  }