简体   繁体   English

为新创建的包文件夹生成gen文件夹

[英]Generate gen folder for new create package folder

I'm working on a project, I have all the clases on the same package, lets suppose: "com.example.project". 我正在做一个项目,我把所有的包都放在同一个包中,让我们假设:“ com.example.project”。

But now I'm getting with many classes so I would like to classify them in packages as for example: "com.example.project.bluetooth", "com.example.project.dialer", etc... 但是现在我遇到了很多类,因此我想将它们分类为软件包,例如:“ com.example.project.bluetooth”,“ com.example.project.dialer”等。

So, to do this, I created a new package the same way I would create a new class. 因此,为此,我以创建新类的相同方式创建了一个新包。 But when created, all the classes inside of it have error with all the R imports. 但是在创建时,其中的所有类在所有R导入中均出错。 I see this is because in the gen folder, there isn't no reference to the new package. 我看到这是因为在gen文件夹中,没有对新软件包的引用。

How can I solve this? 我该如何解决?

You should import yourpackageName.R instead of android.R . 您应该导入yourpackageName.R而不是android.R Hope it helps. 希望能帮助到你。

Note: Eclipse sometimes likes to add an "import android.R" statement at the top of your files that use resources, especially when you ask Eclipse to sort or otherwise manage imports. 注意:Eclipse有时喜欢在使用资源的文件顶部添加“ import android.R”语句,尤其是当您要求Eclipse排序或管理导入时。 This will cause your make to break. 这将导致您的品牌受损。 Look out for these erroneous import statements and delete them.* 请注意这些错误的导入语句并将其删除。*

Replace 更换

import android.R;

with

import com.example.myapp.R;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM