android.R出错

时间:2014-12-07 20:21:02

标签: 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;
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);
    }
}

1 个答案:

答案 0 :(得分:0)

我发现了我的问题。我错过了R.java文件。要添加文件,我只需在src中创建一个名为gen的文件夹然后清理项目,这就创建了R.java文件并删除了我的错误,感谢给出的帮助

相关问题