我正在尝试使用支持V7库实现PopupMenu。所有编译罚款,但是当我尝试调用:在调用发生Android V7支持库弹出式菜单
PopupMenu popup = new PopupMenu(this, v);
popup.getMenu().add(Menu.NONE,MENU_SHARE_A,1,R.string.A);
popup.getMenu().add(Menu.NONE,MENU_SHARE_B,2,R.string.B);
popup.show();
错误:
07-31 17:23:53.365:E/AndroidRuntime(14128): java.lang中。 RuntimeException:二进制XML文件行#17:您必须提供 layout_height属性。
其中提到我认为“abc_popup_menu_item_layout.xml”与此元素:
<android.support.v7.internal.view.menu.ListMenuItemView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?attr/dropdownListPreferredItemHeight"
android:minWidth="196dip"
android:paddingRight="16dip">
这是一个错误还是我做错了什么?
对我而言,这是主题。我在试图打开菜单的单元测试中遇到问题。不知何故主题没有在测试期间设置,我不得不使用context.setTheme(...)手动设置它; –