导入com.android.internal.R无法解析
您好,我正在使用手势,我需要导入,但出现错误
com.android.internal.R;
无法解析导入 com.android.internal.R
请帮助我,请
Hi i am working with Gestures and i need to import but i m getting error
com.android.internal.R;
The import com.android.internal.R cannot be resolved
kindly help me , please
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您没有说明为什么需要访问
com.android.internal.R
,但可悲的事实是您根本无法导入它(“内部”是一个线索,表明它不属于公共 API)。谷歌不会公开这一点,因为它可能会发生变化。可以通过调用
Resources.getSystem()
来获取内部资源。要获取特定资源标识符的值,您必须知道其名称,然后使用如下代码来查找该值:请注意,您使用的任何名称都可能在未来版本的 Android 中消失。
You don't say why you need access to
com.android.internal.R
, but the sad fact is that you simply cannot import it (the "internal" is a clue that it's not part of the public API). Google doesn't expose this because it is subject to change.It is possible to get to the internal resources by calling
Resources.getSystem()
. To get the value of a particular resource identifier, you have to know its name and then use code like the following to find the value:Be aware that any name that you use could disappear in future versions of Android.
我有几个建议:
1) 确保除了 R 相关错误之外没有任何其他错误。在 Eclipse 中右键单击您的项目文件夹,Android Tools ->修复项目属性。
2) 检查并确保您导入了正确的 R。有时可以导入默认的Android.R。
I have a couple suggestions:
1) Make sure you don't have any other errors other than the R-related errors. Right-click your project folder in Eclipse, Android Tools -> Fix Project Properties.
2) Check to make sure you have the correct R imported. Sometimes the default Android.R can be imported.
是的,你可以使用内部 R 和一些肮脏的技巧(肮脏的技巧 = Java 反射)。
举个例子:
Yes you can use the internal R with some dirty trick (dirty trick = Java reflection).
Just an example:
首先,什么是手势?
你的 gen 文件夹中有一个名为 com.android.internal 的包吗?它包含 R.java 吗?
如果没有,请尝试 Eclipse 中的 Project->Clean。如果仍然不起作用,则您的 XML 布局文件中可能存在错误。
First of all, what is Gestures ?
Do you have a package named com.android.internal in your gen folder ? Doest it contain R.java ?
If not, try Project->Clean in Eclipse. If it still doesn't work, you may have an error in your XML layout files.