建立在Android Studio中新的空白活动时意外添加文件 [英] Unexpected file added when creating new blank activity in android studio
问题描述
我得到了新的Android工作室,并创建一个新的空白的活动时,我注意到一件事。
I got the new android studio, and I noticed one thing when creating a new blank activity.
与Java的活性对应的布局是由两次,一次是为一个内容
:
The layout that corresponds with the java for the activity is made twice, once as a content
:
这新布局的精确副本的常规 activity_menu.xml
除了这一个被称为 content_menu.xml
。我也注意到这块code在布局code activity_menu.xml
:
This new layout is an exact replica of the regular activity_menu.xml
except this one is called content_menu.xml
. I also noticed this piece of code in the layout code of activity_menu.xml
:
<include layout="@layout/content_menu" />
这是什么额外的布局呢?我能删除吗?我发现这官方文件,但我仍不很不懂为什么它是必要的。这是不存在的第一个更新...
What is the point of this extra layout? Can I delete it? I found this on the official documentation, but I still don't understand why it is necessary. This wasn't there in the first update...
推荐答案
下面 content_menu
是只为你的 XML名称
版面内容。不要让这个困惑。正如你在菜单中看到活动你会看到的setContentView(R.layout.activity_menu)
Here content_menu
is just a name for your xml
layout content. Don't get confused by this. As you see in your Menu Activity you'll see setContentView(R.layout.activity_menu)
下面的活动被告知,它的布局是在 activity_menu.xml
内容,但在这( activity_menu.xml
)文件,你看到一个包含标记。在包括标签意味着,在 content_menu.xml
另一个名为 XML
文件中的内容必须包含在当前布局内用于地方包括标签。所以,如果要改变内部的内容您可以在 activity_menu.xml
放下一切,因为它,并在 content_menu.xml $ C更改$ C>,这一切都会在你的设计中可见。
Here the activity is told that its layout is the content inside activity_menu.xml
but in this(activity_menu.xml
) file you see an include tag. the include tag means that the content inside another xml
file named content_menu.xml
must be included inside the current layout at the place where include tag is used. so if want to change the internal content you can leave everything in activity_menu.xml
as it is and make your changes in content_menu.xml
and it'll all be visible in your design.
如果你不想让 content_menu.xml
文件,你可以一切从这个文件只是复制到 activity_menu.xml
代替&LT;&包括GT;标签
和删除 content_menu.xml
文件。
and if you don't want the content_menu.xml
file you can just copy everything from this file to activity_menu.xml
in place of <include > tag
and delete the content_menu.xml
file.
这篇关于建立在Android Studio中新的空白活动时意外添加文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!