How To create Simple Calculator Android App in Android Studio like Addition subtraction , multiplication and division etc.
In this Section we will be saying that google play store is very good platform to store our App on Play Store .and create a simple calculator app ,We can easily handle our apps and Update our App Time to Time this simple calculator app and Google play store are not take much more time in Update .For More You Can Download and Install My All App on Google Play Store
Visit my Google Play Store Apps Click on this Link
Visit For Browser 5 G App On google Play Store>>>>>>>>>>
This My Creative App Click on DeepCrazyWorld App>>>>>>>>>>>
To Solve Your Math Calculation Math Solve App >>>>>
Spinner Bottle Game App>>>>>>>>>>>>>>>>>>>>>
This News Nation App News7on>>>>>>>>>>>>>>
Shopping App ZampKart >>>>>>>>>>>>>>>>>>>
Math Equation Solving App>>>>>>>>>>>>>>>>>>>
Event Basis Picture LovingCaring143 App>>>>>>>>>
Here This Blogger Site App to Explore Your Knowledge Download all this Apps By Google Play Store My Blogger Site App Download And Install. create simple calculator android app
Click on Link CrazyCoder>>>>>>>>>>
How To create Scientific calculator Android App in Android Studio
MainActivity.java
package com.deep.calc; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { Button button0, button1, button2, button3, button4, button5, button6, button7, button8, button9, buttonAdd, buttonSub, buttonDivision, buttonMul, button10, buttonC, buttonEqual; EditText deepEditText; float mValueOne, mValueTwo; boolean deepAddition, mSubtract, deepMultiplication, deepDivision; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button0 = (Button) findViewById(R.id.button0); button1 = (Button) findViewById(R.id.button1); button2 = (Button) findViewById(R.id.button2); button3 = (Button) findViewById(R.id.button3); button4 = (Button) findViewById(R.id.button4); button5 = (Button) findViewById(R.id.button5); button6 = (Button) findViewById(R.id.button6); button7 = (Button) findViewById(R.id.button7); button8 = (Button) findViewById(R.id.button8); button9 = (Button) findViewById(R.id.button9); button10 = (Button) findViewById(R.id.button10); buttonAdd = (Button) findViewById(R.id.buttonadd); buttonSub = (Button) findViewById(R.id.buttonsub); buttonMul = (Button) findViewById(R.id.buttonmul); buttonDivision = (Button) findViewById(R.id.buttondiv); buttonC = (Button) findViewById(R.id.buttonC); buttonEqual = (Button) findViewById(R.id.buttoneql); deepEditText = (EditText) findViewById(R.id.edt1); button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deepEditText.setText(deepEditText.getText() + "1"); } }); button2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deepEditText.setText(deepEditText.getText() + "2"); } }); button3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deepEditText.setText(deepEditText.getText() + "3"); } }); button4.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deepEditText.setText(deepEditText.getText() + "4"); } }); button5.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deepEditText.setText(deepEditText.getText() + "5"); } }); button6.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deepEditText.setText(deepEditText.getText() + "6"); } }); button7.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deepEditText.setText(deepEditText.getText() + "7"); } }); button8.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deepEditText.setText(deepEditText.getText() + "8"); } }); button9.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deepEditText.setText(deepEditText.getText() + "9"); } }); button0.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deepEditText.setText(deepEditText.getText() + "0"); } }); buttonAdd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (deepEditText == null) { deepEditText.setText(""); } else { mValueOne = Float.parseFloat(deepEditText.getText() + ""); deepAddition = true; deepEditText.setText(null); } } }); buttonSub.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mValueOne = Float.parseFloat(deepEditText.getText() + ""); mSubtract = true; deepEditText.setText(null); } }); buttonMul.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mValueOne = Float.parseFloat(deepEditText.getText() + ""); deepMultiplication = true; deepEditText.setText(null); } }); buttonDivision.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mValueOne = Float.parseFloat(deepEditText.getText() + ""); deepDivision = true; deepEditText.setText(null); } }); buttonEqual.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mValueTwo = Float.parseFloat(deepEditText.getText() + ""); if (deepAddition == true) { deepEditText.setText(mValueOne + mValueTwo + ""); deepAddition = false; } if (mSubtract == true) { deepEditText.setText(mValueOne - mValueTwo + ""); mSubtract = false; } if (deepMultiplication == true) { deepEditText.setText(mValueOne * mValueTwo + ""); deepMultiplication = false; } if (deepDivision == true) { deepEditText.setText(mValueOne / mValueTwo + ""); deepDivision = false; } } }); buttonC.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deepEditText.setText(""); } }); button10.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { deepEditText.setText(deepEditText.getText() + "."); } }); } }
step wise xml file calculator app android studio
Again that we are well versed with Activity, Layout, Views etc its time to get our hands dirty, and create our second application. This application will have a science quiz app, and user will have option to answer in True or False. Based on what the user enters, we will show the user, whether they selected the correct option or not by simply showing a message saying Correct or Incorrect.
For Quiz App Open Android Studio and go to File → New → New Project. In the New Project window, enter the Application Name as Quiz and company domain as com.technic.calc and Click on Next.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/relative1" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <EditText android:id="@+id/edt1" android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/button1" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/edt1" android:layout_alignEnd="@+id/button4" android:layout_alignRight="@+id/button4" android:layout_marginTop="94dp" android:text="1" /> <Button android:id="@+id/button2" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/button1" android:layout_toStartOf="@+id/button3" android:layout_toLeftOf="@+id/button3" android:text="2" /> <Button android:id="@+id/button3" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/button2" android:layout_centerHorizontal="true" android:text="3" /> <Button android:id="@+id/button4" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/button1" android:layout_toLeftOf="@+id/button2" android:text="4" /> <Button android:id="@+id/button5" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignStart="@+id/button2" android:layout_alignLeft="@+id/button2" android:layout_alignBottom="@+id/button4" android:text="5" /> <Button android:id="@+id/button6" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/button3" android:layout_alignStart="@+id/button3" android:layout_alignLeft="@+id/button3" android:text="6" /> <Button android:id="@+id/button7" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/button4" android:layout_toLeftOf="@+id/button2" android:text="7" /> <Button android:id="@+id/button8" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/button5" android:layout_alignStart="@+id/button5" android:layout_alignLeft="@+id/button5" android:text="8" /> <Button android:id="@+id/button9" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/button6" android:layout_alignStart="@+id/button6" android:layout_alignLeft="@+id/button6" android:text="9" /> <Button android:id="@+id/buttonadd" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignTop="@+id/button3" android:layout_alignEnd="@+id/edt1" android:layout_alignRight="@+id/edt1" android:layout_marginStart="46dp" android:layout_marginLeft="46dp" android:layout_toRightOf="@+id/button3" android:text="+" /> <Button android:id="@+id/buttonsub" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/buttonadd" android:layout_alignStart="@+id/buttonadd" android:layout_alignLeft="@+id/buttonadd" android:layout_alignEnd="@+id/buttonadd" android:layout_alignRight="@+id/buttonadd" android:text="-" /> <Button android:id="@+id/buttonmul" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/buttonsub" android:layout_alignStart="@+id/buttonsub" android:layout_alignLeft="@+id/buttonsub" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:text="*" /> <Button android:id="@+id/button10" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/button7" android:layout_toLeftOf="@+id/button2" android:text="." /> <Button android:id="@+id/button0" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/button8" android:layout_alignStart="@+id/button8" android:layout_alignLeft="@+id/button8" android:text="0" /> <Button android:id="@+id/buttonC" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/button9" android:layout_alignStart="@+id/button9" android:layout_alignLeft="@+id/button9" android:text="C" /> <Button android:id="@+id/buttondiv" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/buttonmul" android:layout_alignStart="@+id/buttonmul" android:layout_alignLeft="@+id/buttonmul" android:layout_alignEnd="@+id/buttonmul" android:layout_alignRight="@+id/buttonmul" android:text="/" /> <Button android:id="@+id/buttoneql" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/button0" android:layout_alignStart="@+id/button10" android:layout_alignLeft="@+id/button10" android:layout_alignEnd="@+id/buttondiv" android:layout_alignRight="@+id/buttondiv" android:layout_marginTop="37dp" android:text="=" /> </RelativeLayout>
Add Ad MOB AD In Android App YouTube Video
Conclusion
We have successfully created a Calculator app in android studio