Simplest calculator app using android studio android workshop

of 20 /20

Embed Size (px)

Transcript of Simplest calculator app using android studio android workshop

  • Date: 6- Feb -2015

    First Android App

    [email protected]

  • Calculator APP with simple ADD functionality


  • package com.baabtra.baabtracalc;

    import;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.widget.EditText;import android.widget.Button;

  • public class LoadingScreen extends ActionBarActivity implements View.OnClickListener { Button mButton; EditText Txt_FirstNumber, Txt_SecondNumber, Txt_Result;

    @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_loading_screen);

  • mButton = (Button)findViewById(; Txt_FirstNumber = (EditText)findViewById(; Txt_SecondNumber = (EditText)findViewById(; Txt_Result = (EditText)findViewById(;



  • public void onClick(View v) { int int_fn = Integer.parseInt(Txt_FirstNumber.getText().toString()); int int_sn= Integer.parseInt(Txt_SecondNumber.getText().toString()); int int_tmp_result = int_fn + int_sn; Txt_Result.setText("Result : " + Integer.toString(int_tmp_result)); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(, menu); return true; }

  • @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId();

    //noinspection SimplifiableIfStatement if (id == { return true; }

    return super.onOptionsItemSelected(item); }}

  • Linear Layout Heading - Baabtranz Calculator three text boxes - First number, Second

    Number and Result Thee labels - TextViews - First Number,

    Second Number and Result One Button - Add button

    Lay out of the app


    7002 Hana Road, Edison NJ 08817, United States of America.

    90 High Street,

    Cherry Hinton,

    Cambridge, CB1 9HZ,

    United Kingdom.

    Suite No: 51, Oasis Center,

    Sheikh Zayed Road, Dubai,


    Email to [email protected] or Visit

    Looking for learning coding or software engineering?

  • India CentresEmarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 495 40 25 550

    NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 495 40 25 550

    Cafit Square IT Park,Hilite Business Park,KozhikodeKerala, India.

    Email: [email protected]

    TBI - NITCNIT Campus, Kozhikode.Kerala, India.

    Start up VillageEranakulam,Kerala, India.

    Start up VillageUL CCKozhikode, Kerala