2014-02-11 36 views
0

我在eclipse中工作,我遇到了許多其他人都有的錯誤,但事情似乎仍然沒有工作。我收到多個佈局無法解析我的drawable和id源的答案。我試着用Cntrl shift O命令我的每一行,但似乎沒有任何工作。多個不能解決的錯誤

我在看我的activity_mainxml文件,但沒有看到任何錯誤,但根據我在這裏閱讀的內容,這可能是問題的根源。

任何想法我可能會失蹤?任何建議將不勝感激。

package com.example.alltruths; 

import android.app.Activity; 
import android.graphics.drawable.AnimationDrawable; 
import android.hardware.Sensor; 
import android.hardware.SensorManager; 
import android.media.MediaPlayer; 
import android.os.Bundle; 
import android.view.Menu; 
import android.view.animation.AlphaAnimation; 
import android.widget.ImageView; 
import android.widget.TextView; 

public class MainActivity extends Activity { 

    private static final String R = null; 
    private AllTruths mAllTruths = new AllTruths(); 
    private TextView mAnswerLabel; 
    private ImageView mAllTruthsImage; 
    private SensorManager mSensorManage; 
    private Sensor mAccelerometer; 
    private ShakeDetector mShakeDetector; 

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


     //Assigning Views from layout 
     mAnswerLabel = (TextView) findViewById(R.id.textView1);  
     mAllTruthsImage = (ImageView) findViewById(R.id.imageView1); 


    } 

回答

0

首先簡單錯誤似乎已經聲明瞭StringR這裏

私有靜態最後絃樂R = NULL;

刪除此行並按下Ctrl鍵++Ø正確導入R.javaR.java自身生成,代碼參考用於訪問您的佈局和其他元素。

0
  1. 刪除String R,你不需要它。
  2. 在您的導入之間添加import com.example.alltruths.R;行。
+0

非常感謝。這擺脫了大部分的錯誤信息。還有一件事似乎仍然存在於我的Drawable代碼中。任何想法這裏可能是錯誤的:mAllTruthsImage.setImageResource(R.Drawable.ball_animation); AnimationDrawable ballAnimation =(AnimationDrawable)mAllTruthsImage.getDrawable(); (ballAnimation.isRunning()){ \t ballAnimation.stop(); } ballAnimation.start(); } – user3261110

+0

@ user3261110,它應該是R.drawable.ball_animation,小寫'd'。如果它對你有幫助,請接受答案。 – Egor

0
mAllTruthsImage.setImageResource(R.Drawable.ball_animation); 

如果被複制並粘貼,問題是資本。它不是。

相關問題