问题描述
开始使用 Android Studio 而不是 Eclipse ADT 处理我的第一个项目.我想添加子文件夹以包含 java.classes 以构建我的应用程序,但无法在我的活动中获取对它们的引用
Started working on my first project using Android Studio instead of Eclipse ADT.I would like to add sub folders to contain java.classes in order to structure my app but are unable to obtain references to them in my activity
结构是(替换了应用程序名称)
structure is (with app name replaced)
src/main/[MyCompany]/[myAppName]/model/user.java
和
src/main/[MyCompany]/[myAppName]/helperClasses/SQLiteHelper.java
但是我无法直接在代码中或通过导入引用它们,并且被迫将它们与活动一起放在 appName 文件夹中以引用它们.
however I am unable to reference them either directly in code or by import, and are forced to put them in the appName folder with the activity to reference them.
这仅仅是 Android 中的一个限制,还是有一种方法可以更好地使用文件夹组织您的项目.我使用了 new->folder-java
文件夹选项来创建文件夹
Is this simply a limitation in Android or is there a way to organize your project with folders better. I used the new->folder-java
folder option to create folders
推荐答案
IntelliJIdea 混合了包和目录.
IntelliJIdea mixes packages and directories.
因此,右键单击 java 文件夹,单击新建 - 'Package',然后添加您的目录.
So, right click on the java folder, click new - 'Package', then add your directory.
这篇关于将java文件夹添加到android studio项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!