Create first android app using Android studio

In this post, we are going to create first android app which will show result of multiplication of two user input numbers. We have already created Android hello world example before but it was too basic.
We are going to design our screen as below:

Android First App

We are not going to put much validations here. We will just create above screen which will show multiplication of two numbers in Result textview.

Steps for creating first android app using Android studio:

Step 1:

Create a new android project named “MultiplicationApp”. Provide Activity name as “MultiplicationActivity” instead of “HelloWorldActivity”.

Step 2:

Go to res -> layout -> activity_multiplication.xml. Paste following code in xml file to create multiplication screen.

Step 3:

Go to app -> java -> package -> MultiplicationActivity.java.
Change MultiplicationActivity.java as below:

To get any widget reference in activity class, you can use id which you have defined in layout xml file. So to get reference for editText corresponds to “Number 1” in the screen, we have used below code:

You can get text entered by user in that edit text by using below code:

We have also put click listener on button named “Multiply”.

Step 4 :

Run the app. When you run above app on emulator, you will get below screen:

Android first app preparation

Provide user input numbers and click on multiply, you will get the result.

Android first app development

We are done with first  android app using android studio.
Happy Android Learning!!

Related Posts

  • 22 January

    FizzBuzz program in Python

    In this post, we will see how to program FizzBuzz in Python. As per wikipedia, Fizz buzz is a group word game for children to teach them about division. Here are the rules of the game: First player starts the game by saying number 1. Next player says next number but fun part is If […]

  • Format double to 2 decimal places in java
    22 January

    7 ways to format double to 2 decimal places in java

    Learn about how to format double to 2 decimal places in java

  • Escape double quotes in String in Java
    19 January

    How to escape double quotes in String in java

    In this post, we will see how to escape double quotes in String in java. There are scenarios where you need to escape double quotes already present in the String. This generally happens while dealing with JSON file format or reading file data. Escape double quotes in java Double quotes characters can be escaped with […]

  • Convert Date to LocalDate in java
    12 January

    Java Date to LocalDate

    In this post, we will see how to convert Date to LocalDate in java. Sometimes, we may need to convert Date to new Java 8 APIs and vice versa. There are multiple ways to convert Date to LocalDate in java. Read also: Convert LocalDate to Date in java Using toInstant() method of Date class You […]

  • Convert LocalDate to Date in java
    11 January

    Java LocalDate to Date

    In this post, we will see how to convert LocalDate to Date. Java 8 has introduced a lot of new APIs for Date and time. There can be many ways to convert Java LocalDateTime to date. Using Instant object You can convert LocalDate to Date using Instant object which we can from Zone. Here is […]

  • 04 January

    How to change java version in intellij

    Learn about how to change java version in intellij.

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.