Tuesday, 13 June 2017

Simple Calculator app in Android

Simple Calculator app in Android

Download Source Code


This post is similar to that of 

Adding two numbers in Android

 We are using different operations like subtraction, multiplication,division and also addition.

Read Working with Multiple Buttons


This example is the combination of the last two post

Adding two numbers in Android and Working with Multiple buttons,so if you have practiced that well this program is easy for you or else practice that both examples and continue this example.


We need to make the design plan.

Simple-Calculator-app-in-Android
Create a new project and Just drag and drop and edit as per in the design.

Simple-Calculator-app-in-Android

The number 1 and Number 2 can be typed using the help of hint property.

To use the hint right click on the Plain Text  and EditHint

add-hint

Then register the buttons,edittext's, textview's in MainActivity.java

onclick-method


After that add switch case statement  as in the last post and include the addition of two numbers example code and also include code for other operations also as in the image.

Simple-Calculator-app-in-Android-source-code

I think it is very easy to understand right! yeah it's so simple to develop android apps than you think if you have basic programming concepts and interest to learn!!!

Let we see the Output

Simple-Calculator-app-in-Android-output

Simple-Calculator-app-in-Android-output


When clicked ADD Button

Simple-Calculator-app-in-Android-output
When Clicked SUB Button

Simple-Calculator-app-in-Android-output
When clicked MUL button

Simple-Calculator-app-in-Android-output
When clicked DIV Button

Simple-Calculator-app-in-Android-output

How to use Android Phone as an Emulator



Practice this example more times and do it without referring any example codes.

It will make you to have strong knowledge in working with buttons.