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]@baabtra.com

  • Calculator APP with simple ADD functionality

    Contents

  • package com.baabtra.baabtracalc;

    import android.support.v7.app.ActionBarActivity;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.widget.EditText;import android.widget.Button;

    LoadingScreen.java

  • 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(R.id.button); Txt_FirstNumber = (EditText)findViewById(R.id.editText); Txt_SecondNumber = (EditText)findViewById(R.id.editText2); Txt_Result = (EditText)findViewById(R.id.editText3);

    mButton.setOnClickListener(this);

    }

  • 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(R.menu.menu_loading_screen, 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 == R.id.action_settings) { 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

  • US UK UAE

    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,

    UAE

    Email to [email protected] or Visit baabtra.com

    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