问题
I have checked the id exists in the R.java file still it shows error here is R.java code
public static final class drawable {
public static final int background=0x7f020000;
public static final int empty=0x7f020001;
}
and here i am getting error
empty=BitmapFactory.decodeResource(getResources(), R.drawable.empty);//0x7f020001);
if i use the value directly from R.java file then it doesn't show any error
i have tried Project->Clean and fix Project properties and restarted eclipse also none of them worked somebody help me figure out this
thanks..
回答1:
I think that maybe is a problem of the imports. Try to check the imports of your class. Sometimes Eclipse imports the R class from the android package and stops using yours.
Remove imports like import android.R
回答2:
R class is regenerated every time when you build your project. You mustn't save int nubmers anywhere else. You should use int values from R class directly
回答3:
In a similar case someone solved this problem by updating his sdk... Not sure if it helps.
来源:https://stackoverflow.com/questions/10035699/cannot-be-resolved-or-is-not-a-field-error-android