Reputation: 838
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.
Upvotes: 81
Views: 196227
Reputation: 735
Right-click on the package or directory, then select new kotlin or java
when new kotlin class or file you can choice What kind of class
Upvotes: 0
Reputation: 49
If you want to see your new Activity's XML representation, you can go to the AndroidManifest.xml file.
You will see your Activity like so:
...
<activity android:name=".MyExerciseActivity"
android:label="My Exercise Chart"
android:parentActivityName=".MainActivity"
/>
<activity android:name=".MainActivity">
...
Upvotes: 0
Reputation: 12819
To add an Activity
using Android Studio.
This step is same as adding Fragment, Service, Widget, and etc. Screenshot provided.
[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.
To add a Service
, or a BroadcastReceiver
, just do the same step.
Upvotes: 130
Reputation: 25
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.
Upvotes: 0
Reputation: 683
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.
Upvotes: 1
Reputation: 14253
In Android Studio 2, just right click on app and select New > Activity > ... to create desired activity type.
Upvotes: 22
Reputation: 3827
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.
Upvotes: 5