Android:选项菜单错误?

时间:2016-03-28 08:47:55

标签: android xml android-menu

当我点击按钮菜单时,我发现错误,但如果我点击下面的菜单错误显示

  

找不到操作栏错误。 android.view.InflateException:二进制XML   文件行#17:二进制XML文件行#17:错误类膨胀   android.support.v7.internal.view.menu.ExpandedMenuView

Logcat:

android.view.InflateException: Binary XML file line #17: Binary XML file line #17: Error inflating class android.support.v7.internal.view.menu.ExpandedMenuView
    at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
    at android.support.v7.view.menu.ListMenuPresenter.getMenuView(ListMenuPresenter.java:101)
    at android.support.v7.app.ToolbarActionBar.getListMenuView(ToolbarActionBar.java:522)
    at android.support.v7.app.ToolbarActionBar.access$400(ToolbarActionBar.java:47)
    at android.support.v7.app.ToolbarActionBar$ToolbarCallbackWrapper.onCreatePanelView(ToolbarActionBar.java:581)
    at android.support.v7.app.AppCompatDelegateImplV7.preparePanel(AppCompatDelegateImplV7.java:1279)
    at android.support.v7.app.AppCompatDelegateImplV7.onKeyDownPanel(AppCompatDelegateImplV7.java:1419)
    at android.support.v7.app.AppCompatDelegateImplV7.onKeyDown(AppCompatDelegateImplV7.java:938)
    at android.support.v7.app.AppCompatDelegateImplV7.dispatchKeyEvent(AppCompatDelegateImplV7.java:905)
    at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:241)
    at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:50)
    at com.android.internal.policy.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2310)
    at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4127)
    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4089)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3820)
    at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3981)
    at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2253)
    at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1874)
    at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1865)
    at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2230)
    at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:323)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class android.support.v7.internal.view.menu.ExpandedMenuView
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
    at android.support.v7.view.menu.ListMenuPresenter.getMenuView(ListMenuPresenter.java:101) 
    at android.support.v7.app.ToolbarActionBar.getListMenuView(ToolbarActionBar.java:522) 
    at android.support.v7.app.ToolbarActionBar.access$400(ToolbarActionBar.java:47) 
    at android.support.v7.app.ToolbarActionBar$ToolbarCallbackWrapper.onCreatePanelView(ToolbarActionBar.java:581) 
    at android.support.v7.app.AppCompatDelegateImplV7.preparePanel(AppCompatDelegateImplV7.java:1279) 
    at android.support.v7.app.AppCompatDelegateImplV7.onKeyDownPanel(AppCompatDelegateImplV7.java:1419) 
    at android.support.v7.app.AppCompatDelegateImplV7.onKeyDown(AppCompatDelegateImplV7.java:938) 
    at android.support.v7.app.AppCompatDelegateImplV7.dispatchKeyEvent(AppCompatDelegateImplV7.java:905) 
    at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:241) 
    at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:50) 
    at com.android.internal.policy.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2310) 
    at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4127) 
    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4089) 
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642) 
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695) 
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661) 
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787) 
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669) 
    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844) 
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642) 
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695) 
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661) 
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669) 
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642) 
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695) 
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661) 
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3820) 
    at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3981) 
    at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2253) 
    at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1874) 
    at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1865) 
    at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2230) 
    at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141) 
    at android.os.MessageQueue.nativePollOnce(Native Method) 
    at android.os.MessageQueue.next(MessageQueue.java:323) 
    at android.os.Looper.loop(Looper.java:135) 
    at android.app.ActivityThread.main(ActivityThread.java:5417) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

main_menu.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.se_ed.current.CurrentActivity" >

<item
    android:id="@+id/main_menu_clear_all_recents"
    android:showAsAction="never"
    android:title="Clear Recents"/>

2 个答案:

答案 0 :(得分:0)

如果您项目中的</menu>看起来与此处的相同,则应添加结束标记<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:context="com.se_ed.current.CurrentActivity" > <item android:id="@+id/main_menu_clear_all_recents" android:showAsAction="never" android:title="Clear Recents"/> .... more items .... </menu> ,如下所示:

uri->segement

答案 1 :(得分:0)

完整的main_menu.xml

d=obj.d