的R.java文件不能与UI元素的ID更新 [英] R.java file not updating with UI element's id
问题描述
我加了一些UI元素的main.xml中的文件在res \布局文件夹,当我试图通过电话访问它们, R.layout.my_uielement
,我创建的UI元素是不存在的。甚至当我与UI元素添加一个新的XML文件,它仍然无法在 R.layout
类出现。我已经检查了他们的ID,他们有正确的格式(我认为):机器人:ID =@ + ID / my_button
。可能是什么问题?我需要首先编译code?
更新:
我已经尝试过 ADB杀死服务器
然后亚行启动服务器
。它似乎并没有帮助。我也曾尝试 R.id.my_uielement
,它没有任何注册。
I added some UI elements to the main.xml file in the res\layout folder and when I try to access them through the call, R.layout.my_uielement
, the UI element that I created is not there. Even when I add a new xml file with UI elements, it still doesn't show up in the R.layout
class. I have made checked the ids on them and they have the correct format (I think): android:id="@+id/my_button"
. What could be the problem? Do I need to compile the code first?
UPDATE:
I have already tried adb kill-server
then adb start-server
. It doesn't seem to help. I have also tried R.id.my_uielement
, it doesn't register either.
推荐答案
这可能不是你的情况,但有时当我使用的东西从android.R包(默认的Android资源),我在我的课用它参照从我自己的资源包任何事情之前,Eclipse中添加进口android.R;我进口
语句。这将与含蓄看在你的包资源的默认行为发生冲突。
This may not be the case for you, but sometimes when I use something from the android.R package (default android resources) and I use it in my class before making reference to anything from my own resource package, Eclipse adds the import android.R;
statement in my imports. This will conflict with the default behavior of implicitly looking in your package's resources.
检查import语句进口Android.R;
。如果它的存在,将其删除。而且,如果你使用的是从android.R什么,完全限定它,当你在code使用它。
Check your import statements for import Android.R;
. If it's there, remove it. And, if you're using anything from android.R, fully qualify it when you use it in code.
这篇关于的R.java文件不能与UI元素的ID更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!