FileDocCategorySizeDatePackage
MenuInflater_Delegate.javaAPI DocAndroid 5.1 API3164Thu Mar 12 22:22:44 GMT 2015android.view

MenuInflater_Delegate

public class MenuInflater_Delegate extends Object
Delegate used to provide new implementation of a select few methods of {@link MenuInflater}

Through the layoutlib_create tool, the original methods of MenuInflater have been replaced by calls to methods of the same name in this delegate class.

The main purpose of the class is to get the view key from the menu xml parser and add it to the menu item. The view key is used by the IDE to match the individual view elements to the corresponding xml tag in the menu/layout file.

For Menus, the views may be reused and the {@link MenuItem} is a better object to hold the view key than the {@link MenuView.ItemView}. At the time of computation of the rest of {@link ViewInfo}, we check the corresponding view key in the menu item for the view and add it

Fields Summary
Constructors Summary
Methods Summary
static voidregisterMenu(MenuInflater thisInflater, MenuItem menuItem, android.util.AttributeSet attrs)

        if (menuItem instanceof BridgeMenuItemImpl) {
            Context context = thisInflater.getContext();
            while (context instanceof ContextThemeWrapper) {
                context = ((ContextThemeWrapper) context).getBaseContext();
            }
            if (context instanceof BridgeContext) {
                Object viewKey = BridgeInflater.getViewKeyFromParser(
                        attrs, ((BridgeContext) context), null, false);
                ((BridgeMenuItemImpl) menuItem).setViewCookie(viewKey);
                return;
            }
        }
        // This means that Bridge did not take over the instantiation of some object properly.
        // This is most likely a bug in the LayoutLib code.
        Bridge.getLog().warning(LayoutLog.TAG_BROKEN,
                "Action Bar Menu rendering may be incorrect.", null);

    
static voidregisterMenu(MenuInflater thisInflater, SubMenu subMenu, android.util.AttributeSet parser)

        registerMenu(thisInflater, subMenu.getItem(), parser);