FileDocCategorySizeDatePackage
BridgeMenuItemImpl.javaAPI DocAndroid 5.1 API2489Thu Mar 12 22:22:44 GMT 2015com.android.internal.view.menu

BridgeMenuItemImpl

public class BridgeMenuItemImpl extends MenuItemImpl
An extension of the {@link MenuItemImpl} to store the view cookie also.

Fields Summary
private Object
viewCookie
An object returned by the IDE that helps mapping each View to the corresponding XML tag in the layout. For Menus, we store this cookie here and attach it to the corresponding view at the time of rendering.
private com.android.layoutlib.bridge.android.BridgeContext
mContext
Constructors Summary
BridgeMenuItemImpl(MenuBuilder menu, int group, int id, int categoryOrder, int ordering, CharSequence title, int showAsAction)
Instantiates this menu item.

        super(menu, group, id, categoryOrder, ordering, title, showAsAction);
        Context context = menu.getContext();
        while (context instanceof ContextThemeWrapper) {
            context = ((ContextThemeWrapper) context).getBaseContext();
        }
        if (context instanceof BridgeContext) {
            mContext = ((BridgeContext) context);
        }
    
Methods Summary
public java.lang.ObjectgetViewCookie()

        return viewCookie;
    
public voidsetViewCookie(java.lang.Object viewCookie)

        // If the menu item has an associated action provider view,
        // directly set the cookie in the view to cookie map stored in BridgeContext.
        View actionView = getActionView();
        if (actionView != null && mContext != null) {
            mContext.addViewKey(actionView, viewCookie);
            // We don't need to add the view cookie to the this item now. But there's no harm in
            // storing it, in case we need it in the future.
        }
        this.viewCookie = viewCookie;