Android Studio 中的新目录与新文件夹 [英] New Directory vs New Folder in Android Studio

查看:55
本文介绍了Android Studio 中的新目录与新文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android Studio 中新建目录和新建文件夹有什么区别?

这是菜单选项的图像:

解决方案

简短回答

在将文件夹添加到 Android Studio 项目时使用文件夹.这就是 Android Studio 对它们的称呼.目录 是 IntelliJ 所谓的文件夹.Android Studio 基于 IntelliJ 构建,因此存在一些命名混乱.

长答案

尽管文件夹和目录之间存在技术差异(参见 建立在 IntelliJ IDEA.IntelliJ 本身有一个菜单选项来添加目录(如您所见 此处).但是 Android 将文件存储在它所谓的文件夹中.因此,当将这两个平台放在 Android Studio 中时,会出现一些命名混乱.(这是我的解释,但也许他们真的想区分目录和文件夹之间的细微差别.)

您可以从菜单图片中看到还有一个Android 资源目录";选项.(您可以通过右键单击 res 目录/文件夹而不是子目录来实现.)您可以使用它来添加资源文件夹,例如原始、菜单、值等.

What is the difference between creating a new directory and creating a new folder in Android Studio?

Here is an image of the menu choices:

解决方案

Short answer

Use folder when adding a folder to an Android Studio project. This is what Android Studio calls them. Directory is what IntelliJ calls a folder. Android Studio is built on top IntelliJ so there is some naming confusion.

Long answer

Although there is a technical difference between a folder and a directory (see here and here), they are often (correctly or incorrectly) used interchangeably. This can be seen even in the titles of these two SO questions:

This can be confusing to new users of Android Studio when they see both choices in the menu structure. Further confusion results when users add a new directory and then it doesn't show up in the Android folder view. See these questions for example:

The folders actually do show up if you select the Project or Packages view from the menu:

However if you want an Android folder to show up automatically in the Android view you need to right click and use New > Folder > Assets folder (if you are adding an assets folder). You could then add a subfolder like "fonts" to this by choosing the New > Directory option.

Android Studio is built on top of IntelliJ IDEA. IntelliJ itself has a menu option to add a directory (as you can see here). But Android stores files in what it calls folders. So when these two platforms are put together in Android Studio, there gets to be some naming confusion. (This is my interpretation, but perhaps they really are trying to differentiate the subtle differences between directory and folder.)

You can see from your menu image that there is also an "Android resource directory" option. (You got that by right clicking on the res directory/folder rather than a subdirectory.) You would use this to add resource folders such as raw, menu, values, etc.

这篇关于Android Studio 中的新目录与新文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆