View
632
Download
0
Category
Preview:
Citation preview
Date: 6- Feb -2015
First Android App
info@baabtra.comharis@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
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:orientation="vertical"
android:layout_height="match_parent" tools:context=".LoadingScreen" >
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="@string/heading" android:id="@+id/textView3" android:background="#ff1623ff" android:capitalize="characters" android:clickable="false" android:textColor="#ff35ffb6" android:textSize="@dimen/abc_action_bar_progress_bar_size" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text= "@string/first_number" android:id="@+id/textView2" />
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="number" android:ems="10" android:id="@+id/editText" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="@string/second_number" android:id="@+id/textView4" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="number" android:ems="10" android:id="@+id/editText2" />
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text= "@string/Result" android:id="@+id/textView" />
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="number" android:id="@+id/editText3" />
<Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="ADD" android:id="@+id/button" />
</LinearLayout>
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 info@baabtra.com or Visit baabtra.com
Looking for learning coding or software engineering?
India Centres
Emarald 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: info@baabtra.com
TBI - NITCNIT Campus, Kozhikode.Kerala, India.
Start up VillageEranakulam,Kerala, India.
Start up VillageUL CCKozhikode, Kerala
Recommended