Android的V7支持库弹出菜单 [英] Android V7 Support Library Popup Menu
问题描述
我想实现的PopupMenu与支持V7库。所有编译正常,但当我尝试调用:
I'm trying to implement a PopupMenu with the Support V7 Library. All compiles fine but when I try to call:
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();
在通话时发生错误:
an error occurs on call:
07-31 17:23:53.365:E / AndroidRuntime(14128): java.lang.RuntimeException的:二进制XML文件中的行#17:必须提供 一个layout_height属性。
07-31 17:23:53.365: E/AndroidRuntime(14128): java.lang.RuntimeException: Binary XML file line #17: You must supply a layout_height attribute.
这是指我觉得abc_popup_menu_item_layout.xml这个元素:
Which refers I think to "abc_popup_menu_item_layout.xml" with this element:
<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">
这是一个错误还是我做错了什么?
Is this is a bug or do I do something wrong?
推荐答案
您可能要检查,如果你有你的清单文件中指定一个合适的主题:
You might want to check if you have an appropriate theme specified in your manifest file:
<application ... android:theme="@style/Theme.AppCompat">
这篇关于Android的V7支持库弹出菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!