[android] How to add new activity to existing project in 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.

This question is related to android android-studio

The answer is


In Android Studio, go to app -> src -> main -> java -> com.example.username.projectname

Right click on com.example.username.projectname -> Activity -> ActivityType

Fill in the details of the New Android Activity and click Finish.

Viola! new activity added to the existing project.


In Android Studio, go to app --> src --> main --> res-->

File --> new --> Activity --> ActivityType [choose a acticity that you want]

Fill in the details of the New Android Activity and click Finish.


I think natually do it is straightforward, whether Intellij IDEA or Android Studio, I always click new Java class menu, and then typing the class name, press Enter to create. after that, I manually typing "extends Activity" in the class file, and then import the class by shortcut key. finally, I also manually override the onCreate() method and invoke the setContentView() method.


In Android Studio 2, just right click on app and select New > Activity > ... to create desired activity type.

enter image description here