Android studio how to create new activity

To create a new activity in Android Studio, follow these steps:

  1. Open your project in Android Studio.
  2. In the Project panel, right-click on the app folder (or the package name) and select "New" > "Activity" > "Empty Activity".
  3. In the "Create New Activity" dialog box, select the following options:
    • Activity type: Empty Activity
    • Language: Java (or Kotlin, depending on your preference)
    • Name: Enter a name for your activity (e.g., "MainActivity")
    • Package name: Leave this field blank
    • Save location: Choose a location to save your activity (e.g., "app/src/main/java")
  4. Click "Finish" to create the new activity.

Android Studio will create a new Java or Kotlin file for your activity, along with a corresponding XML layout file. The activity will be added to your project's manifest file (AndroidManifest.xml).

Here's a breakdown of the files that Android Studio creates:

You can customize the activity by modifying the code in the Java or Kotlin file, and the layout in the XML file. You can also add additional files and resources to your activity as needed.

Note: If you want to create a new activity with a specific template (e.g., a list activity or a fragment activity), you can select the corresponding option in the "Create New Activity" dialog box.