简体   繁体   English

MainActivity.java错误

[英]MainActivity.java errors

Im getting trouble compiling a simple hello world app. 我在编译一个简单的hello world应用程序时遇到了麻烦。

I am getting errors in my mainActivity.java file and not sure whats wrong. 我在mainActivity.java文件中遇到错误,不确定是怎么回事。

This was created by Eclipse. 这是由Eclipse创建的。

R. is coming up as an error when trying to compile/Run. R.在尝试编译/运行时出现错误。

Here are the errors shown in the compiler: 这是编译器中显示的错误:

错误

package com.example.myfirstapp;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;


public class MainActivity extends ActionBarActivity {

    @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);
    }
}

请执行以下步骤:-1-右键单击项目>构建路径>配置构建路径2-库>删除Android依赖关系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM