【发布时间】:2019-08-13 20:36:43
【问题描述】:
我刚刚开始使用 android,我的 hello world 应用程序遇到了问题,问题首先是它说 R 无法解决,我能够克服,因为没有 R.java 文件,我后来从互联网 现在有三个错误 1.activity_main 无法解析或者不是字段 2.menu无法解析或者不是字段 3. action_settings 无法解析或不是字段
我已经尝试过control+shift+o, 已经尝试过清理和构建。
package my.hello;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
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;
}
@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();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}强文本
【问题讨论】: