所以我的弹出菜单在4.0手机上工作正常,但在较低版本上抛出此异常。 我现在一直试图找出几个小时的东西,没有解决方案。
这里是菜单XML,我不确定我是否应该查看另一个布局文件:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
>
<group android:id="@+id/group_popupmenu">
<item android:id="@+id/menu1"
android:title="@string/remove_recipient"/>
<item android:id="@+id/menu2"
android:title="@string/assign_resp"/>
</group>
</menu>
这是它设置的地方:
public void showPopupMenu(final RecipientChip chip) {
PopupMenu popupMenu = new PopupMenu(_cont, this);
popupMenu.getMenuInflater().inflate(
R.menu.resp_popupmenu, popupMenu.getMenu());
if (!_responsibilityEnabled)
hideOption(R.id.menu2, popupMenu.getMenu());
...
我真的不确定我做错了什么。我似乎已查看了XML文件的原因:
FATAL EXCEPTION: main
java.lang.RuntimeException: Binary XML file line #17: You must supply a layout_height attribute.
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:491)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:3599)
at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:3678)
at android.widget.FrameLayout$LayoutParams.<init>(FrameLayout.java:457)
at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:423)
at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:47)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.support.v7.internal.view.menu.MenuPopupHelper$MenuAdapter.getView(MenuPopupHelper.java:335)
at android.support.v7.internal.view.menu.MenuPopupHelper.measureContentWidth(MenuPopupHelper.java:190)
at android.support.v7.internal.view.menu.MenuPopupHelper.tryShow(MenuPopupHelper.java:128)
at android.support.v7.internal.view.menu.MenuPopupHelper.show(MenuPopupHelper.java:102)
at android.support.v7.widget.PopupMenu.show(PopupMenu.java:108)
at com.path.ChipTextView.showPopupMenu(ChipTextView.java:420)
at com.path.RecipientChip$1.onClick(RecipientChip.java:233)
at com.path.ChipTextView$MyMovementMethod.onTouchEvent(ChipTextView.java:610)
at android.widget.TextView.onTouchEvent(TextView.java:6863)
at android.view.View.dispatchTouchEvent(View.java:3885)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125)
at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
at com.path.FragmentActivity.dispatchTouchEvent(FragmentActivity.java:97)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675)
at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2194)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1878)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)