TechBeamersTechBeamers
  • Learn ProgrammingLearn Programming
    • Python Programming
      • Python Basic
      • Python OOP
      • Python Pandas
      • Python PIP
      • Python Advanced
      • Python Selenium
    • Python Examples
    • Selenium Tutorials
      • Selenium with Java
      • Selenium with Python
    • Software Testing Tutorials
    • Java Programming
      • Java Basic
      • Java Flow Control
      • Java OOP
    • C Programming
    • Linux Commands
    • MySQL Commands
    • Agile in Software
    • AngularJS Guides
    • Android Tutorials
  • Interview PrepInterview Prep
    • SQL Interview Questions
    • Testing Interview Q&A
    • Python Interview Q&A
    • Selenium Interview Q&A
    • C Sharp Interview Q&A
    • PHP Interview Questions
    • Java Interview Questions
    • Web Development Q&A
  • Self AssessmentSelf Assessment
    • Python Test
    • Java Online Test
    • Selenium Quiz
    • Testing Quiz
    • HTML CSS Quiz
    • Shell Script Test
    • C/C++ Coding Test
Search
  • Python Multiline String
  • Python Multiline Comment
  • Python Iterate String
  • Python Dictionary
  • Python Lists
  • Python List Contains
  • Page Object Model
  • TestNG Annotations
  • Python Function Quiz
  • Python String Quiz
  • Python OOP Test
  • Java Spring Test
  • Java Collection Quiz
  • JavaScript Skill Test
  • Selenium Skill Test
  • Selenium Python Quiz
  • Shell Scripting Test
  • Latest Python Q&A
  • CSharp Coding Q&A
  • SQL Query Question
  • Top Selenium Q&A
  • Top QA Questions
  • Latest Testing Q&A
  • REST API Questions
  • Linux Interview Q&A
  • Shell Script Questions
© 2024 TechBeamers. All Rights Reserved.
Reading: Create Android App Using Android Studio
Font ResizerAa
TechBeamersTechBeamers
Font ResizerAa
  • Python
  • SQL
  • C
  • Java
  • Testing
  • Selenium
  • Agile Concepts Simplified
  • Linux
  • MySQL
  • Python Quizzes
  • Java Quiz
  • Testing Quiz
  • Shell Script Quiz
  • WebDev Interview
  • Python Basic
  • Python Examples
  • Python Advanced
  • Python OOP
  • Python Selenium
  • General Tech
Search
  • Programming Tutorials
    • Python Tutorial
    • Python Examples
    • Java Tutorial
    • C Tutorial
    • MySQL Tutorial
    • Selenium Tutorial
    • Testing Tutorial
  • Top Interview Q&A
    • SQL Interview
    • Web Dev Interview
  • Best Coding Quiz
    • Python Quizzes
    • Java Quiz
    • Testing Quiz
    • ShellScript Quiz
Follow US
© 2024 TechBeamers. All Rights Reserved.
Android

Create Android App Using Android Studio

Last updated: Feb 25, 2024 12:37 pm
By Meenakshi Agarwal
Share
5 Min Read
SHARE

The following tutorial explains the procedure to create an Android app with basic features using Android Studio. It will help you climb the first step towards learning Android Development.

Contents
Create the Android App in StudioAdd Activity to Android AppUpdate Android App XML FileUpdate MainActivity.java FileSummary

The app will have a simple UI and a few lines of Java code so that you can get started with Android development. And you can certainly make it more feature-rich after acquiring the basic acknowledge.

We’ll make use of Android Development Studio and explain how to use it in a step-by-step manner. The tutorial is also using images to attribute the action you need to perform.

How to Create an App Using Android Studio

Create the Android App in Studio

1. Start Android Studio

Start Android Studio

2. On the screen above, click on “Start a new Android Studio Project.”

Create Android App using Android Studio

Name your application as “MyFirstProject” and then click next.

Target Android Devices

Add Activity to Android App

In this step, we’ll add an empty activity to our app. For this, please click on the Next button on the screen shown below.

Add an Activity to Android App

Now, select the Empty Activity template from the options and click on the Next button.

Select Empty Activity for Android App

Click on the Finish button.

Also Read: Switch between Activities in Android

Update Android App XML File

Now in the res folder, go to the activity_main.xml file in the layout folder and write the following code.

# Remember that here we are creating our first project and thus we will create a screen displaying the message “Hello World” and a “Click Me” Button.

In the text, tab copy the following code.

The following .xml file is the layout file for the MainActivity. You create interactive UIs here.

This file has a TextView and a Button which can be brought to the design screen by drag and drop method from the left panel.

Practice: Try placing various elements in your sample screen.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.soumyaagarwal.myfirstproject.MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:layout_centerInParent="true"
android:textColor="#000000"
android:textSize="40dp"
android:textStyle="bold"
android:id="@+id/textView" />

<Button
android:text="Click Me"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true"
android:layout_marginTop="61dp"
android:id="@+id/button" />
</RelativeLayout>

Update MainActivity.java File

In the Java folder, go to the MainActivity.java file in your package and write the following code.

Here an ‘id’ to the button is given, and then Click Listener is set. On clicking this “Click Me” button, we get to see a toast (a short message displaying “The Button is clicked !”

package com.example.soumyaagarwal.myfirstproject;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivityextends AppCompatActivity {

   Button clickme; 

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);

      clickme= (Button)findViewById(R.id.button);

      clickme.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            Toast.makeText(MainActivity.this,
                           "The Button is clicked !",
                           Toast.LENGTH_LONG).show();
         }
      });
   }
}

Now we need to run our first project. Although we have already installed the Genymotion emulator, still running apps on real devices is speedy. Hence, connect your Android device to your PC and click on the run option on the toolbar.

You will find the following dialogue box.

Write Java code for the Android App

Select the device that you have connected and click on the OK button.

Now, let the Gradle build complete. After that, you’ll see your first app getting launched on your Android device.

Also Read: Setup Genymotion Emulator with Android Studio

Below are the screenshots of the app launched.

Launching Android App

When you click on the “CLICK ME” Button, the toast appears.

Android App Started

Summary

Kongo! You are done with making your First Android Application. We hope that you will now be able to add more features and functionality to this app.

If you have any queries regarding the above code, do leave a reply. Also, you should also read the below Android Studio tutorial to know how to set it up correctly.

Android Development Studio Tutorial for Beginners

You Might Also Like

Must-have Android Apps for Every Mobile User and Blogger

Simple Android Data Analytics App in Python

File Transfer on Android (5 Ways)

Create an Android App in Python

Programming Language for Android in 2024

TAGGED:Android Apps Made for Developers
Meenakshi Agarwal Avatar
By Meenakshi Agarwal
Follow:
Hi, I'm Meenakshi Agarwal. I have a Bachelor's degree in Computer Science and a Master's degree in Computer Applications. After spending over a decade in large MNCs, I gained extensive experience in programming, coding, software development, testing, and automation. Now, I share my knowledge through tutorials, quizzes, and interview questions on Python, Java, Selenium, SQL, and C# on my blog, TechBeamers.com.
Previous Article Python Multiple Inheritance with Examples Python Multiple Inheritance – A Practical Guide for You
Next Article Switch between activities in Android How to Switch between Activities in Android

Popular Tutorials

SQL Interview Questions List
50 SQL Practice Questions for Good Results in Interview
SQL Interview Nov 01, 2016
Demo Websites You Need to Practice Selenium
7 Sites to Practice Selenium for Free in 2024
Selenium Tutorial Feb 08, 2016
SQL Exercises with Sample Table and Demo Data
SQL Exercises – Complex Queries
SQL Interview May 10, 2020
Java Coding Questions for Software Testers
15 Java Coding Questions for Testers
Selenium Tutorial Jun 17, 2016
30 Quick Python Programming Questions On List, Tuple & Dictionary
30 Python Programming Questions On List, Tuple, and Dictionary
Python Basic Python Tutorials Oct 07, 2016
//
Our tutorials are written by real people who’ve put in the time to research and test thoroughly. Whether you’re a beginner or a pro, our tutorials will guide you through everything you need to learn a programming language.

Top Coding Tips

  • PYTHON TIPS
  • PANDAS TIPSNew
  • DATA ANALYSIS TIPS
  • SELENIUM TIPS
  • C CODING TIPS
  • GDB DEBUG TIPS
  • SQL TIPS & TRICKS

Top Tutorials

  • PYTHON TUTORIAL FOR BEGINNERS
  • SELENIUM WEBDRIVER TUTORIAL
  • SELENIUM PYTHON TUTORIAL
  • SELENIUM DEMO WEBSITESHot
  • TESTNG TUTORIALS FOR BEGINNERS
  • PYTHON MULTITHREADING TUTORIAL
  • JAVA MULTITHREADING TUTORIAL

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

Loading
TechBeamersTechBeamers
Follow US
© 2024 TechBeamers. All Rights Reserved.
  • About
  • Contact
  • Disclaimer
  • Privacy Policy
  • Terms of Use
TechBeamers Newsletter - Subscribe for Latest Updates
Join Us!

Subscribe to our newsletter and never miss the latest tech tutorials, quizzes, and tips.

Loading
Zero spam, Unsubscribe at any time.
x