Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.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
Java android.R出现错误_Java_Android_Eclipse_Error Handling_Syntax Error - Fatal编程技术网

Java android.R出现错误

Java android.R出现错误,java,android,eclipse,error-handling,syntax-error,Java,Android,Eclipse,Error Handling,Syntax Error,嗨,我正在开发一个android应用程序,没什么特别的,只是一些适合大学的小东西。当我使用R时,我在最后一位收到一个错误。示例R.id.mediAware 任何帮助都将不胜感激 以下是我的代码,如果有帮助的话: package com.example.medicalapp; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu;

嗨,我正在开发一个android应用程序,没什么特别的,只是一些适合大学的小东西。当我使用R时,我在最后一位收到一个错误。示例R.id.mediAware 任何帮助都将不胜感激

以下是我的代码,如果有帮助的话:

package com.example.medicalapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.medicalapp.R;

public class MainActivity extends Activity {

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

        ImageView img1 = (ImageView) findViewById(R.id.mediAware);
        ImageView splash_image2 = (ImageView) findViewById(R.id.mediAware2);


        Animation fade1 = AnimationUtils.loadAnimation(this, R.anim.fadein);
        Animation fade2 = AnimationUtils.loadAnimation(this, R.anim.fadein2);


        fade2.setAnimationListener(new AnimationListener() {
            public void onAnimationEnd (Animation animation) {

                Intent intent = new Intent(new Intent(MainActivity.this, MenuActivity.class));
                startActivity(intent);
            }
            public void onAnimationStart(Animation animation){
            }
            public void onAnimationRepeat(Animation animation){
            }
        });
        splash_image.startAnimation(fade1);
        splash_image2.startAnimation(fade2);
    }

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

我解决了我的问题。我丢失了R.java文件。要添加文件,我只需在src中创建一个名为gen的文件夹,然后清理项目,这创建了R.java文件并删除了我的错误,感谢提供的帮助

尝试执行“清理构建”,然后重新构建。引用文件服务器时出现问题。我进行了清理和重建,现在所有活动都包含RMO错误。大多数情况下,当您出现此类错误时,是因为XML布局中的其他地方有错误,请检查布局和清单是否有任何编码错误。清单文件中没有任何内容。如果我只是简单地创建了一个新项目,那么默认情况下第一个项目是完美的,如果我添加了第二个活动并且没有立即编辑任何内容,那么我会收到与R相关的错误,而不会在第二个活动中操作任何代码