RuntimeException:无法解析索引6处的属性

时间:2016-08-10 13:17:21

标签: android menu

我有一个片段的按钮。当我点击按钮时,它应显示弹出菜单。但它确实很糟糕。

这些是我的错误消息:

  

E / AndroidRuntime:致命异常:主要                     过程:com.ias.caniasandroid,PID:22823                     java.lang.RuntimeException:无法解析索引6处的属性                         在android.content.res.TypedArray.getLayoutDimension(TypedArray.java:603)                         在android.view.ViewGroup $ LayoutParams.setBaseAttributes(ViewGroup.java:6473)                         在android.view.ViewGroup $ MarginLayoutParams。(ViewGroup.java:6641)                         在android.widget.FrameLayout $ LayoutParams。(FrameLayout.java:741)                         在android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:685)                         在android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:62)                         在android.view.LayoutInflater.inflate(LayoutInflater.java:492)                         在android.view.LayoutInflater.inflate(LayoutInflater.java:414)                         在android.support.v7.view.menu.MenuPopupHelper $ MenuAdapter.getView(MenuPopupHelper.java:374)                         在android.support.v7.view.menu.MenuPopupHelper.measureContentWidth(MenuPopupHelper.java:223)                         在android.support.v7.view.menu.MenuPopupHelper.tryShow(MenuPopupHelper.java:157)                         在android.support.v7.view.menu.MenuPopupHelper.show(MenuPopupHelper.java:129)                         在android.support.v7.widget.PopupMenu.show(PopupMenu.java:216)

我的菜单XML文件:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <item
        android:id="@+id/login_menu_new_item"
        android:orderInCategory="100"
        android:title="@string/new_ias"
        app:showAsAction="ifRoom|withText" />
    <item
        android:id="@+id/login_menu_edit_item"
        android:orderInCategory="100"
        android:title="@string/edit"
        app:showAsAction="ifRoom|withText" />
    <item
        android:id="@+id/login_menu_delete_item"
        android:orderInCategory="100"
        android:title="@string/delete"
        app:showAsAction="ifRoom|withText" />
</menu>

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:-1)

可能是因为style.css文件过多。

在build.gradle文件中添加以下内容:

compile 'com.android.support:design:22.2.0'