-1

To better organize my classes, I made a few sub-packages (that is an extension in the package's hierarchical name structure).

But to my surprise I have been getting an R cannot be resolved to a variable for like every resource I am trying to use from this project's R file.

The Eclipse's quick fixes options do give the option of importing the particular R file for the package (which contains the sub-packages), But the question is that in the package that I created in the Eclipse's New Application Project wizard, I did not need to import the R file at all, and I always thought it contained the resources for this entire project.

But now after creating sub-packages, I need to import it. SO asking out of curiosity, since a sub-package is nothing (in Java) but an extension in the hierarchical name structure of the package itself (reference), then why doesn't the R file automatically get included in the sub-packages?

4

1 回答 1

1

R只是一个与任何其他类一样的类(除了 Eclipse 为您创建它并使用您的资源 ID 更新它)。

它包含在一个包中 - 就像其他所有类一样。

如果你想从不同的包中使用它,你必须导入它或使用完全限定的名称——就像你对任何其他类一样。

于 2015-01-08T01:21:30.457 回答