BridgeMenuItemImplpublic class BridgeMenuItemImpl extends MenuItemImpl An extension of the {@link MenuItemImpl} to store the view cookie also. |
Fields Summary |
---|
private Object | viewCookieAn 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.Object | getViewCookie()
return viewCookie;
| public void | setViewCookie(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;
|
|