Mobile Application Development – Android Studio Tool Download
Hi guys, I am Prabakaran, Welcome to innovative codes academy, In this section we learn about
How to do download android studio software and open new project?
Click on below link:
Android Studio Tool Download link given below:
https://developer.android.com/studio
How to do develop mini calculator application in android studio tool? Easily make android app.
JAVA Source Code:
MainActivity.java
package com.example.minicalculator;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
EditText tv1,tv2,tv3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv1=findViewById(R.id.t1);
tv2=findViewById(R.id.t2);
tv3=findViewById(R.id.t3);
}
public void add(View v)
{
int a=Integer.parseInt(tv1.getText().toString());
int b=Integer.parseInt(tv2.getText().toString());
int result=a+b;
tv3.setText(String.valueOf(result));
}
public void sub(View v)
{
int a=Integer.parseInt(tv1.getText().toString());
int b=Integer.parseInt(tv2.getText().toString());
int result=a-b;
tv3.setText(String.valueOf(result));
}
public void mul(View v)
{
int a=Integer.parseInt(tv1.getText().toString());
int b=Integer.parseInt(tv2.getText().toString());
int result=a*b;
tv3.setText(String.valueOf(result));
}
}
XML Source Code:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:stretchColumns="*">
<TableRow>
<EditText android:width="220dp" android:hint="Enter the First number" android:id="@+id/t1" />
</TableRow>
<TableRow>
<EditText android:width="220dp" android:hint="Enter the Second number" android:id="@+id/t2" />
</TableRow>
<TableRow>
<EditText android:width="220dp" android:hint="Result" android:id="@+id/t3" />
</TableRow>
<TableRow>
<Button android:text="Addition" android:width="100dp" android:onClick="add"/>
</TableRow>
<TableRow>
<Button android:text="Subtraction" android:width="100dp" android:onClick="sub"/>
</TableRow>
<TableRow>
<Button android:text="Multiplication" android:width="100dp" android:onClick="mul"/>
</TableRow>
</TableLayout>
AndroidManifest(File):
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.minicalculator"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
Click on below link:
Android Studio Tool Download link given below:
https://developer.android.com/studio
Mobile Application Development – Build your application in Apk format
How to do build your application in Apk format and How to do open new file in your project?
Android Studio Tool Download link given below:
https://developer.android.com/studio
Mobile Application Development – Build your Mobile application Calculator in Android Studio Tool
How to develop Mobile Calculator in Android Studio Tool?
Using Rhino Library Package:
Rhino Library Package:https://github.com/F43nd1r/rhino-android
Google Fonts:https://fonts.google.com/
You want source code contact me:
innovativecodesacacademy1@gmail.com
watch full video, Any doubt or quires leave comment with your mail, I will chat with you.
JAVA Source Code:
MainActivity.java
package com.example.calculator_01;
import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; import org.mozilla.javascript.Context; import org.mozilla.javascript.Scriptable; public class MainActivity extends AppCompatActivity { Button btn0,btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,
btnBracket,btnClear,btnPercent,btnDivide,btnMultiplication,
btnMinus,btnAddition,btnEqual,btnDot;
TextView tvinput,tvoutput;
String process;
Boolean checkbracket=false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn0 =findViewById(R.id.btn0);
btn1 =findViewById(R.id.btn1);
btn2 =findViewById(R.id.btn2);
btn3 =findViewById(R.id.btn3);
btn4 =findViewById(R.id.btn4);
btn5 =findViewById(R.id.btn5);
btn6 =findViewById(R.id.btn6);
btn7 =findViewById(R.id.btn7);
btn8 =findViewById(R.id.btn8);
btn9 =findViewById(R.id.btn9);
btnDivide =findViewById(R.id.btnDivide);
btnAddition =findViewById(R.id.btnAddition);
btnMinus =findViewById(R.id.btnSubtraction);
btnMultiplication =findViewById(R.id.btnMultiply);
btnPercent =findViewById(R.id.btnPercent);
btnBracket =findViewById(R.id.btnBracket);
btnClear =findViewById(R.id.btnclear);
btnEqual =findViewById(R.id.btnEqual);
btnDot =findViewById(R.id.btnDot);
tvinput =findViewById(R.id.tvinput);
tvoutput =findViewById(R.id.tvoutput);
btnClear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tvinput.setText("");
tvoutput.setText("");
}
});
btn0.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"0");
}
});
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"1");
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"2");
}
});
btn3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"3");
}
});
btn4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"4");
}
});
btn5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"5");
}
});
btn6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"6");
}
});
btn7.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"7");
}
});
btn8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"8");
}
});
btn9.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"9");
}
});
btnMultiplication.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"x");
}
});
btnAddition.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"+");
}
});
btnMinus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"-");
}
});
btnDivide.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"÷");
}
});
btnPercent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+"%");
}
});
btnDot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
tvinput.setText(process+".");
}
});
btnBracket.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(checkbracket)
{
process =tvinput.getText().toString();
tvinput.setText(process+")");
checkbracket=false;
}
else
{
process =tvinput.getText().toString();
tvinput.setText(process+"(");
checkbracket=true;
}
}
});
btnEqual.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
process =tvinput.getText().toString();
process =process.replaceAll("x","*");
process =process.replaceAll("%","/100");
process =process.replaceAll("÷","/");
Context rhino = Context.enter();
rhino.setOptimizationLevel(-1);
String finalresult="";
try {
Scriptable scriptable = rhino.initStandardObjects();
finalresult=rhino.evaluateString(scriptable,process,"javascript",1,null).toString();
}
catch (Exception e)
{
finalresult="0";
}
tvoutput.setText(finalresult);
}
});
}
}
XML Source Code:
Below XML code for Connect the two file input.xml and buttons.xml in activity_main.xmlactivity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:background="@color/white">
<include
layout="@layout/input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
layout="@layout/buttons"
android:layout_height="wrap_content"
android:layout_width="match_parent"
/>
</RelativeLayout>
</LinearLayout>
Buttons Creations:buttons.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="6"
android:rowCount="5">
<Button
android:id="@+id/btnclear"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="0"
android:layout_column="0"
android:text="C"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/black"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btnBracket"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="0"
android:layout_column="1"
android:text="()"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/black"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btnPercent"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="0"
android:layout_column="2"
android:text="%"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/black"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btnDivide"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="0"
android:layout_column="3"
android:text="÷"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/blue"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btn7"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="1"
android:layout_column="0"
android:text="7"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/black"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btn8"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="1"
android:layout_column="1"
android:text="8"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/black"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btn9"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_row="1"
android:layout_column="2"
android:background="@color/white"
android:fontFamily="@font/got"
android:text="9"
android:textColor="@color/black"
android:textSize="25sp" />
<Button
android:id="@+id/btnMultiply"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="1"
android:layout_column="3"
android:text="x"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/blue"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btn4"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="2"
android:layout_column="0"
android:text="4"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/black"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btn5"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="2"
android:layout_column="1"
android:text="5"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/black"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btn6"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="2"
android:layout_column="2"
android:text="6"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/black"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btnSubtraction"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="2"
android:layout_column="3"
android:text="-"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/blue"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btn1"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="3"
android:layout_column="0"
android:text="1"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/black"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_row="3"
android:layout_column="1"
android:background="@color/white"
android:fontFamily="@font/got"
android:text="2"
android:textColor="@color/black"
android:textSize="25sp" />
<Button
android:id="@+id/btn3"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="3"
android:layout_column="2"
android:text="3"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/black"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btnAddition"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="3"
android:layout_column="3"
android:text="+"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/blue"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btn0"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="4"
android:layout_column="0"
android:text="0"
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/black"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btnDot"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="4"
android:layout_column="1"
android:layout_columnSpan="2"
android:layout_columnWeight="1"
android:text="."
android:textSize="25sp"
android:background="@color/white"
android:textColor="@color/black"
android:fontFamily="@font/got"
/>
<Button
android:id="@+id/btnEqual"
android:layout_height="100dp"
android:layout_width="wrap_content"
android:layout_row="4"
android:layout_column="3"
android:text="="
android:textSize="25sp"
android:background="@color/blue"
android:textColor="@color/black"
android:fontFamily="@font/got"
/>
</GridLayout>
</RelativeLayout>
Input and Output Text Box Creation:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:background="@color/white"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvinput"
android:text=""
android:textSize="30dp"
android:textColor="@color/black"
android:padding="20dp"
android:gravity="end"
android:fontFamily="@font/got"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvoutput"
android:text=""
android:textSize="30dp"
android:textColor="@color/black"
android:padding="20dp"
android:gravity="end"
/>
</LinearLayout>AndroidManifest(File):<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.calculator_01">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Click on below link:
https://youtu.be/rJhomr8b9c4
Android Studio Tool Download link given below:
https://developer.android.com/studio
Channel link:
https://www.youtube.com/channel/UCX1KgUr3ZA6cCR81qGGpA6g?sub_confirmation=1