2014-12-07 25 views
-1

您好我正在開發一個Android應用程序,沒有什麼花哨只是一些小的大學。當我使用R I最終位收到一個錯誤。例如R.id. mediAware 任何幫助將不勝感激。誤差android.R

這裏是我的代碼是否有幫助:

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); 
    } 
} 
+0

嘗試做一個「乾淨的構建」,然後幫助重建。引用R文件時出錯 – moffeltje 2014-12-07 20:23:44

+0

我做了一個清理和重建,現在所有活動都包含R的錯誤 – 2014-12-07 20:56:34

+0

大多數情況下,當您遇到這種錯誤時,是因爲在您的XML佈局的其他地方出現錯誤,檢查你的佈局和清單的任何編碼錯誤。 – 2014-12-07 23:20:10

回答

0

我想通了,我的問題。我錯過了R.java文件。要添加我只是創造了SRC稱爲根文件夾,然後清洗項目中的文件,這創造了R.java文件並刪除我的錯誤,明白這是給