How to add new activity to an existing project in Android Studio?

In Eclipse, you just clicked on a new button and select android activity to add new activity. But Android Studio is a little different; I could not learn how to add new activity to the project.

+74
android android-studio
May 20 '13 at 2:17
source share
5 answers

To add Activity using Android Studio.

This step is the same as adding a fragment, service, widget, etc. Screenshots

[UPDATE] In Android Studio 0.5.4

  • In the main application project, go to the src folder.

    enter image description here

  • Double-click src to expand.

    enter image description here

  • Right-click the main or java folder. New > Activity .

    enter image description here


[Android studio 0.5.3 and below]

  • In your project, go to the java folder (src > main) > right click either the java folder or a package name > New > Android Component .
  • Now the next step will be easy for you. Hurrah!:)

To add Service , Application , Remote Interface or BroadcastReceiver , follow the same step.

+117
May 20 '13 at 2:26
source share
β€” -

In Android Studio 2, simply right-click on the application and select Create> Activity> ... to create the type of activity you want.

enter image description here

+18
Oct 20 '16 at 8:14
source share

I think this is straightforward, be it Intellij IDEA or Android Studio, I always select the new Java class menu, and then entering the class name, press Enter to create. after that I manually type "extends Activity" in the class file, and then import the class using the shortcut key. finally, I also manually override the onCreate () method and call the setContentView () method.

+5
May 20 '13 at 2:35
source share

In Android Studio, go to app β†’ src β†’ main β†’ java β†’ com.example.username.projectname

Right-click com.example.username.projectname β†’ Activity β†’ ActivityType.

Enter information about the new Android action and click " Finish . "

Viola! new activity added to existing project.

+1
Jan 04 '18 at 18:07
source share

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

File β†’ new β†’ Activity β†’ ActivityType [select the desired activity]

Enter information about the new Android action and click "Finish."

0
Jul 08 '19 at 9:23
source share



All Articles