如何在 Android Studio 中向现有项目添加新活动?

如何在 Android Studio 中向现有项目添加新活动?

问题描述:

在 Eclipse 中,您只需单击新按钮并选择 android 活动以添加新活动.但 Android Studio 有点不同;我不知道如何向项目添加新活动.

In Eclipse you just clicked the new button and select the android activity to add new activity. But Android Studio is a bit diferent; I couldn't find out how to add new activity to the project.

使用 Android Studio 添加 Activity.

To add an Activity using Android Studio.

此步骤与添加 Fragment、Service、Widget 等相同,提供截图.

This step is same as adding Fragment, Service, Widget, and etc. Screenshot provided.

[更新] Android Studio 3.5.请注意,我已经删除了旧版本的步骤.我假设几乎所有人都在使用 3.x 版.

[UPDATE] Android Studio 3.5. Note that I have removed the steps for the older version. I assume almost all is using version 3.x.

  1. 右键单击java包/java文件夹/模块,我建议选择一个java包然后右键单击它,以便将活动的目的地保存在那里
  2. 选择/点击新建
  3. 选择活动
  4. 选择您要创建的活动,可能是基本活动.

要添加 ServiceBroadcastReceiver,只需执行相同的步骤即可.

To add a Service, or a BroadcastReceiver, just do the same step.