我正在从 Udacity 学习 Android 初学者开发并完成了一个名为 Court Counter 的应用程序的制作,我在其中编写了 XML (activity_main.xml) 代码和 Java (MainActivity.java) 文件的一些代码,因为一些代码是由 Udacity 提供的团队 Github .
但是当我点击“构建 APK”时,我从 Java 文件中得到了两个错误:
无法解析以下代码中的符号“菜单”:-
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; }
无法解析符号“action_settings”:-
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); }
我不知道执行这些代码块时会发生什么,但我想在我的手机上运行该应用程序!
最佳答案
凭借 20 多年的经验,我可以告诉您一个非常困难的解决 android studio 菜单问题的方法...:
************ 关闭项目并再次打开它 ************************
关于java - 无法解决 Android Studio 中的符号 'menu' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38226254/