Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android MenuInflater问题_Android - Fatal编程技术网

Android MenuInflater问题

Android MenuInflater问题,android,Android,这是我当前遇到的错误: public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boole

这是我当前遇到的错误:

public class MainActivity extends Activity {

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
   }


   @Override
   public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
   }

}

尝试使用getSupportMenuInflater

The method inflate(int, android.view.Menu) in the type MenuInflater is not applicable for the arguments (int, com.example.thebasicstweekz.Menu)
The method onCreateOptionsMenu(Menu) of type MainActivity must override or implement a supertype method
而不是

getSupportMenuInflater().inflate(R.menu.main, menu);

导入菜单-应该是android.view.Menu

您尝试过DDMS透视图了吗

您是否尝试过“Android”或“LogCat”的窗口>视图搜索


谢谢

您正在使用eclipse吗?在底部应该有一个标签,上面写着logcat,包含您的错误。你能看到吗?camn ypu显示完整代码??你在使用ActionBarSherlock吗?我们真的不需要更多的代码来告诉你的问题。当您必须传入一个
android.view.Menu
时,您正在传入一个
com.example.basicstweekz.Menu
。它在你的错误中写着正确。什么是ActionBarSherlock?将我添加到skype上,并告诉我一些plz,以便我将来更容易获得帮助?:)我明白了,谢谢你们的帮助,真是个好社区。。
 getMenuInflater().inflate(R.menu.main, menu);