diff --git a/api/current.xml b/api/current.xml
index 528761006c982..24ada9923a2ae 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -220683,6 +220683,105 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
true if the event was handled, false otherwise.
+ */
+ public boolean onMenuItemClick(MenuItem item);
+ }
+}
diff --git a/core/java/com/android/internal/view/menu/MenuPopupHelper.java b/core/java/com/android/internal/view/menu/MenuPopupHelper.java
index 9913c00994062..ce0ec045dc0bc 100644
--- a/core/java/com/android/internal/view/menu/MenuPopupHelper.java
+++ b/core/java/com/android/internal/view/menu/MenuPopupHelper.java
@@ -76,12 +76,14 @@ public class MenuPopupHelper implements AdapterView.OnItemClickListener, View.On
mPopup.setAdapter(adapter);
mPopup.setModal(true);
- if (mMenu instanceof SubMenuBuilder) {
+ if (mAnchorView != null) {
+ mPopup.setAnchorView(mAnchorView.get());
+ } else if (mMenu instanceof SubMenuBuilder) {
SubMenuBuilder subMenu = (SubMenuBuilder) mMenu;
final MenuItemImpl itemImpl = (MenuItemImpl) subMenu.getItem();
mPopup.setAnchorView(itemImpl.getItemView(MenuBuilder.TYPE_ACTION_BUTTON, null));
- } else if (mAnchorView != null) {
- mPopup.setAnchorView(mAnchorView.get());
+ } else {
+ throw new IllegalStateException("MenuPopupHelper cannot be used without an anchor");
}
mPopup.setContentWidth(Math.min(measureContentWidth(adapter), mPopupMaxWidth));