Cannot be resolved or is not a field error android

ε祈祈猫儿з 提交于 2020-01-03 05:18:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!