Simple calculator Android app development using Android Studio

Published on . Written by

Simple calculator Android app development using Android Studio

Android studio is the official IDE (Integrated Development Environment) for the android operating system developed by Google. It is built on Jetbrain’s IJ (IntelliJ IDEA) software. In this android studio project, you will create a simple calculator android application using Android Studio.


Skyfi Labs Projects
Before getting started let’s look into some basics:

Read more..

SLNOTE
Software development kit: SDK is a set of tools that consists of an executable program which includes, frameworks, emulators, debuggers, documentation, profilers, libraries, etc. Android Studio already comes along with an Android SDK.

Editor and IDE: In general you can create an android app using a normal text editor like notepad++ but mostly IDE like the android studio is used. IDE makes it more user-friendly by combining all the SDK tools and helps to manage them easily.

Plugin - To automate project tasks libraries are used. Plugins are software add-on which is used to improve the abilities of the tool.

Advantages of Android Studio:

  • Android studio allows better app indexing. Android Studio IDE helps to create and index URL links to the app.
  • It comes with a faster emulator which installs and runs the app faster than real.
  • Easy adoption if you know java you can easily get adopt to this IDE and can create code for mobile applications.
  • With Android Studio, you can easily integrate with other apps in background which allows you to perform a wide variety of customisations.
  • It is open-source software which reduces the development and licensing cost by providing the Software Development Kit for free.

SLLATEST
Project Implementation:

1. Let’s start by creating a new project from file>new project> and save it as a calculator.

2. Now select the minimum SDK as per your wish and click next.

3. Choose the empty activity module there are many activities available like Google map activity, login activity, scrolling activity, etc.

4. Now in the customize activity dialogue box leave the name as it is Main activity since we are going to have only one activity in our app. Click on Finish.

5. In App>res>layout>activity_mail.xml you can able to see app layout.

6. In our calculator app, we are going to have two text view, one is used to give the input by the user and other is to display the result. And four buttons are used in this app Addition, subtraction, multiplication and division.

7. We are going to use vertical layout so go-to text editor and type orientation= ”vertical”. Now the orientation has been set. Let’s work on the UI.

8. Add two text views and four buttons in the layout and change the ID for all the text views and buttons.

9. Change the text on the buttons using the editor. Type “textSize = 2sp” to change the size of the text.

10. Now go to Mainactivity.java and declare the following variables:

TextView result;

EditText number1, number 2;

Button add, subtract, divide, multiply;

11. Now write the actual program for the calculator. Refer the below example for add function:

num1 = Integer.parseInt{(number1,getText(),toString()};

num2 = Integer.parseInt{(number2.getText(),toString()};

result_num - num1 + num2;

result.setText(String.valueof(result_num));

Similarly write the code for subtraction, multiplication and division.

12. Click on Play and test the calculator app.


SLDYK
Kit required to develop Simple calculator Android app development using Android Studio:
Technologies you will learn by working on Simple calculator Android app development using Android Studio:


Any Questions?


Subscribe for more project ideas