我正在尝试在应用程序中创建菜单,但是当我运行应用程序时,出现错误,并且当我单击菜单时该错误消失了,我知道dou会出现此错误,我该如何纠正它对我有帮助请...这是出现的错误 菜单代码
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/meu_showmsg"
android:icon="@drawable/menuh"
android:state_pressed="true"
android:title="@string/se_connecter"
app:showAsAction="always" />
</menu>
代码活动
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.meu_showmsg:
new MaterialDialog.Builder(this)
.title("Se connecter").show();
break;
}
return super.onOptionsItemSelected(item);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.bein_markt_menu, menu);
return super.onCreateOptionsMenu(menu);
}
}
logcat
E/AndroidRuntime: FATAL EXCEPTION: main
Process: zied.aloui.beinmarkt, PID: 3780
android.content.res.Resources$NotFoundException: Resource ID #0x7f060063
at android.content.res.Resources.getValue(Resources.java:1351)
at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:328)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
at android.support.v7.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:491)
at android.support.v7.view.menu.ActionMenuItemView.initialize(ActionMenuItemView.java:125)
at android.support.v7.widget.ActionMenuPresenter.bindItemView(ActionMenuPresenter.java:210)
at android.support.v7.view.menu.BaseMenuPresenter.getItemView(BaseMenuPresenter.java:187)
at android.support.v7.widget.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:196)
at android.support.v7.widget.ActionMenuPresenter.flagActionItems(ActionMenuPresenter.java:476)
at android.support.v7.view.menu.MenuBuilder.flagActionItems(MenuBuilder.java:1164)
at android.support.v7.view.menu.BaseMenuPresenter.updateMenuView(BaseMenuPresenter.java:95)
at android.support.v7.widget.ActionMenuPresenter.updateMenuView(ActionMenuPresenter.java:229)
at android.support.v7.view.menu.MenuBuilder.dispatchPresenterUpdate(MenuBuilder.java:291)
at android.support.v7.view.menu.MenuBuilder.onItemsChanged(MenuBuilder.java:1051)
at android.support.v7.view.menu.MenuBuilder.startDispatchingItemsChanged(MenuBuilder.java:1078)
at android.support.v7.app.AppCompatDelegateImplV9.preparePanel(AppCompatDelegateImplV9.java:1419)
at android.support.v7.app.AppCompatDelegateImplV9.doInvalidatePanelMenu(AppCompatDelegateImplV9.java:1657)
at android.support.v7.app.AppCompatDelegateImplV9$1.run(AppCompatDelegateImplV9.java:134)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
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)
答案 0 :(得分:1)
此:
android.content.res.Resources$NotFoundException: Resource ID #0x7f060063
和这个:
at android.support.v7.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:491)
表示您用于菜单的图标之一可能不存在,也许您拼错了。