In my android application i created a menu with two actions save and refresh and called inside another activity.
在我的Android应用程序中,我创建了一个菜单,其中包含两个操作保存和刷新,并在另一个活
But it gives this exception, how to resolve this. Didn't find class “android.view.menu” on path
但它给出了这个例外,如何解决这个问题。没有在路径上找到类“android.view.menu”
Here is my code ,
这是我的代码,
This is my main.xml inside main,
这是main里面的main.xml,
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_refresh"
android:orderInCategory="100"
android:showAsAction="always|withText"
android:title="@string/menu_refresh"/>
<item
android:id="@+id/menu_save"
android:icon="@android:drawable/ic_menu_save"
android:orderInCategory="10"
android:showAsAction="always"
android:title="@string/menu_save"/>
</menu>
and this how am calling inside my activity,
这就是我在我的活动中如何调用,
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_refresh:
return true;
case R.id.menu_save:
return true;
}
return false;
}
Here is my log
这是我的日志
android.view.InflateException: Binary XML file line #1: Error inflating class menu
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.os.Handler.dispatchMessage(Handler.java:99)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.os.Looper.loop(Looper.java:137)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-23 07:48:05.277: E/AndroidRuntime(1097): at java.lang.reflect.Method.invokeNative(Native Method)
07-23 07:48:05.277: E/AndroidRuntime(1097): at java.lang.reflect.Method.invoke(Method.java:511)
07-23 07:48:05.277: E/AndroidRuntime(1097): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-23 07:48:05.277: E/AndroidRuntime(1097): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-23 07:48:05.277: E/AndroidRuntime(1097): at dalvik.system.NativeStart.main(Native Method)
07-23 07:48:05.277: E/AndroidRuntime(1097): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class menu
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:807)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
07-23 07:48:05.277: E/AndroidRuntime(1097): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.app.Activity.setContentView(Activity.java:1881)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.SampleApp.AndroidDashboardDesignActivity.onCreate(AndroidDashboardDesignActivity.java:28)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.app.Activity.performCreate(Activity.java:5104)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-23 07:48:05.277: E/AndroidRuntime(1097): ... 11 more
07-23 07:48:05.277: E/AndroidRuntime(1097): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.menu" on path: /data/app/android.SampleApp-1.apk
07-23 07:48:05.277: E/AndroidRuntime(1097): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
07-23 07:48:05.277: E/AndroidRuntime(1097): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-23 07:48:05.277: E/AndroidRuntime(1097): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:643)
07-23 07:48:05.277: E/AndroidRuntime(1097): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
07-23 07:48:05.277: E/AndroidRuntime(1097): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
1 个解决方案
#1
0
Did you put the menu.xml file in /res/menu/menu.xml
您是否将menu.xml文件放在/res/menu/menu.xml中
You might get this error when the menu.xml is within /layout/
当menu.xml在/ layout /中时,您可能会收到此错误
#1
0
Did you put the menu.xml file in /res/menu/menu.xml
您是否将menu.xml文件放在/res/menu/menu.xml中
You might get this error when the menu.xml is within /layout/
当menu.xml在/ layout /中时,您可能会收到此错误