任何事情都无法解决 [英] R.raw.anything cannot be resolved
问题描述
在我的应用程序中,我尝试读取一个文件:data.xml。我把它放在res / raw /,并且访问它我应该使用getRessources()。openRawResource(R.raw.data);
但Eclipse显示我有一个错误:数据无法解决或不是一个字段。
但是该字段位于gen / R.java !!!
public final class R {
public static final class raw {
public static final int data = 0x7f040000;
}
}
任何想法?
感谢
解决方案:
导入正确的R.java文件!
import my_package.R;
停止信任ctrl + shift + O ...
几周前我已经面临这个问题了。您只需使用 com.example.R
(其中 com.example
是您的包的名称),因为Eclipse认为您默认使用 android.R
。
尝试这个。
I'm developing an android apps with Eclipse.
In my app, I try to read a file : data.xml. I put it in res/raw/, and to access it i'm supposed to use getRessources().openRawResource(R.raw.data);
But Eclipse show me an error : "data" cannot be resolved or is not a field.
But the field is in the gen/R.java !!!
public final class R {
public static final class raw {
public static final int data=0x7f040000;
}
}
Any ideas ? Thanks
Solution : Import the right R.java files ! import my_package.R;
Stop trusting ctrl+shift+O ...
I already faced this problem several weeks ago. You simply have to use com.example.R
(where com.example
is the name of your package), because Eclipse thinks that you are using android.R
by default.
Try this out.
这篇关于任何事情都无法解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!