Eclipse会自动导入R

发布于 2024-12-28 10:05:34 字数 150 浏览 3 评论 0原文

我正在 Eclipse 中开发 Android 应用程序。 Eclipse 有时会自动导入 R,所以我只需单击 (ctrl + shift + o) 即可找到导入并删除它。但现在,每次删除,无论删除多少次,它都会恢复。

有谁知道如何解决这个问题,以便我能够编译我的项目?

I am developing an android application in Eclipse. Eclipse sometimes imports R automatically so I just click (ctrl + shift + o) to find that import and delete it. But now, every time I delete it, it will bring it back no matter how many times I delete it.

Does anyone know how to solve this problem so I will be able to compile my project?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

挖个坑埋了你 2025-01-04 10:05:34

当您使用自动完成功能时,Eclipse 将尝试为相关类型构建导入语句。这是一个可配置选项,您可以在 Eclipse 的首选项对话框 Java ->; 下禁用它。编辑->内容辅助“添加导入而不是限定名称” 不过,这不能在每个包的基础上进行配置。

然而,我确实想知道您反对导入资源类的原因是什么。您是否只想始终完全限定对 R 的引用?我不知道有什么技术原因可以解释为什么这可能更好。如果这是风格问题,那么我想说这可能是一种误导性的偏好。就我个人而言,我宁愿不必定期阅读散布导入的完全限定类名的源文件。如果您的需求都不是这些,也许您可​​以分享更多细节,以便我们可以给您更好的答案?

Eclipse will try to construct an import statement for related types when you use auto-complete. This is a configurable option which you can disable under Eclipse's preferences dialog Java -> Editor -> Content Assist "Add import instead of qualified name" This is not configurable on a per package basis though.

I do wonder, however, what your objection is to importing your resource class. Is it that you just want references to R to always be fully qualified? I don't know of any technical reason why this might be preferable. If it's an issue of style, then I'd interject that it might be a misguided preference. Personally, I'd rather not have to regularly read source files that interspersed imported and fully-qualified class names. If your need is neither of these things, perhaps you could share more detail so that we can give you a better answer?

泪意 2025-01-04 10:05:34

您是否使用任何 android.R 类,如果是,请将其删除。
如果没有,请尝试在保存文件之前手动添加 app.R 导入。
我知道这很烦人,但这就是 Eclipse 自动导入的工作方式......

您也可以尝试从 Eclipse 中删除自动导入设置。

Are you using any android.R classes,if yes remove it.
If no try to add your app.R import manually before saving the file.
I know this is annoying but thats how eclipse works for auto import....

you can also try removing automatically import settings from eclipse.

〗斷ホ乔殘χμё〖 2025-01-04 10:05:34

原来是我的设置有问题。感谢大家的帮助。

It turns out that there was something wrong with my settings. Thanks everyone for there help.

尹雨沫 2025-01-04 10:05:34

就我而言,它会自动添加到项目首选项中的 appcompat_v7 中。我不知道它是如何以及为什么在 Eclipse 中完成的,大多数情况下它会导致这个问题。

在此处输入图像描述

In my case it was automatically added appcompat_v7 in project preferences. I have no idea how and why it is done in eclipse and mostly it causes this problem.

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文