Mobile Application Development Lab [] Simple Android Application for Native Calculator. To develop a Simple Android Application for Native Calculator.

Similar documents
M.A.D Assignment # 1

CSE 660 Lab 7. Submitted by: Arumugam Thendramil Pavai. 1)Simple Remote Calculator. Server is created using ServerSocket class of java. Server.

Basic GUI elements - exercises

Tip Calculator. xmlns:tools=" android:layout_width="match_parent"

Intents. Your first app assignment

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

M.A.D ASSIGNMENT # 2 REHAN ASGHAR BSSE 15126

ANDROID PROGRAMS DAY 3

ITU- FAO- DOA- TRCSL. Training on. Innovation & Application Development for E- Agriculture. Shared Preferences

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Managing Screen Orientation

TextView Control. EditText Control. TextView Attributes. android:id - This is the ID which uniquely identifies the control.

MAD ASSIGNMENT NO 3. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

StoppUhr. <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="start1"

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

<uses-permission android:name="android.permission.internet"/>

MAD ASSIGNMENT NO 2. Submitted by: Rehan Asghar BSSE AUGUST 25, SUBMITTED TO: SIR WAQAS ASGHAR Superior CS&IT Dept.

Android Programs Day 5

Arrays of Buttons. Inside Android


Data Persistence. Chapter 10

android-espresso #androidespresso

Manifest.xml. Activity.java

Fragment Example Create the following files and test the application on emulator or device.

Create Parent Activity and pass its information to Child Activity using Intents.

Dynamically Create Admob Banner and Interstitial Ads

Adaptation of materials: dr Tomasz Xięski. Based on presentations made available by Victor Matos, Cleveland State University.

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

else if(rb2.ischecked()) {

Mobile Software Development for Android - I397

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Switching UIs

Vienos veiklos būsena. Theory

Software Practice 3 Before we start Today s lecture Today s Task Team organization

Simple Currency Converter

EMBEDDED SYSTEMS PROGRAMMING UI Specification: Approaches


android:layout_margintop="5dp" > <EditText android:layout_width="210dp"

Text Properties Data Validation Styles/Themes Material Design

Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.

PENGEMBANGAN APLIKASI PERANGKAT BERGERAK (MOBILE)

Android Workshop: Model View Controller ( MVC):

Android Beginners Workshop

Android Tutorial: Part 3

1. Location Services. 1.1 GPS Location. 1. Create the Android application with the following attributes. Application Name: MyLocation

Our First Android Application

Introduction to Android Development

App Development for Smart Devices. Lec #7: Audio, Video & Telephony Try It Out

Meniu. Create a project:

IPN-ESCOM Application Development for Mobile Devices. Extraordinary. A Web service, invoking the SOAP protocol, in an Android application.

Fragments. Lecture 11

Database Development In Android Applications

Android HelloWorld - Example. Tushar B. Kute,

android:orientation="horizontal" android:layout_margintop="30dp"> <Button android:text="button2"

COMP61242: Task /04/18

Thread. A Thread is a concurrent unit of execution. The thread has its own call stack for methods being invoked, their arguments and local variables.

Screen Slides. The Android Studio wizard adds a TextView to the fragment1.xml layout file and the necessary code to Fragment1.java.

Android CardView Tutorial

Tabel mysql. Kode di PHP. Config.php. Service.php

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 4. Workshop

Notification mechanism

API Guide for Gesture Recognition Engine. Version 2.0

Android/Java Lightning Tutorial JULY 30, 2018

COMP4521 EMBEDDED SYSTEMS SOFTWARE

Android UI Development

Android Application Development. By : Shibaji Debnath

Starting Another Activity Preferences

Created By: Keith Acosta Instructor: Wei Zhong Courses: Senior Seminar Cryptography

Computer Science E-76 Building Mobile Applications


UI (User Interface) overview Supporting Multiple Screens Touch events and listeners

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)


User Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr.

10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics

ELET4133: Embedded Systems. Topic 15 Sensors

Figure 2.10 demonstrates the creation of a new project named Chapter2 using the wizard.

Interface ใน View class ประกอบด วย

API Guide for Gesture Recognition Engine. Version 1.1

Practical 1.ListView example

Android Layout Types

APPENDIX CODE TO STORE THE BUTTON MENU AND MOVE THE PAGE

LAB MANUAL SITTTR KALAMASSERY SMART DEVICE PROGRAMMING LAB. SITTTR Smart Device Programming Manual Page 1

Lecture 14. Android Application Development

Android Specifics. Jonathan Diehl (Informatik 10) Hendrik Thüs (Informatik 9)

Kotlin for Android developers

Open Lecture Mobile Programming. Intro to Material Design

The Definitive Guide to Firebase

Android Services. Victor Matos Cleveland State University. Services

Embedded Systems Programming - PA8001

Laying Out Controls in Containers

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH

Android Apps Development for Mobile Game Lesson 5

Accelerating Information Technology Innovation

TPCT s College of Engineering, Osmanabad. Laboratory Manual SDL-II. Mobile Application Development (Android) For. Third Year Students (CSE)

Android - JSON Parser Tutorial

// MainActivity.java ; Noah Spenser; Senior Design; Diabetic Breathalyzer

Developed and taught by well-known Contact author and developer. At public for details venues or onsite at your location.

Mobile Computing Practice # 2c Android Applications - Interface

Press project on the left toolbar if it doesn t show an overview of the app yet.

Transcription:

Simple Android Application for Native Calculator Aim: To develop a Simple Android Application for Native Calculator. Procedure: Creating a New project: Open Android Stdio and then click on File -> New -> New project. Then type the Application name as ex.no.3 and click Next. S.Gokulakrishnan AP/CSE SCSVMV Page 1

Then select the Minimum SDK as shown below and click Next. Then select the Empty Activity and click Next. S.Gokulakrishnan AP/CSE SCSVMV Page 2

Finally click Finish. It will take some time to build and load the project. After completion it will look as given below. S.Gokulakrishnan AP/CSE SCSVMV Page 3

Designing layout for the Android Application: Click on app -> res -> layout -> activity_main.xml. Now click on Text as shown below. Then delete the code which is there and type the code as given below. S.Gokulakrishnan AP/CSE SCSVMV Page 4

Code for Activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_height="match_parent" android:layout_margin="20dp"> <LinearLayout android:id="@+id/linearlayout1" android:layout_margin="20dp"> <EditText android:id="@+id/edittext1" android:inputtype="numberdecimal" android:textsize="20sp" /> <EditText android:id="@+id/edittext2" android:inputtype="numberdecimal" android:textsize="20sp" /> </LinearLayout> <LinearLayout android:id="@+id/linearlayout2" android:layout_margin="20dp"> <Button android:id="@+id/add" android:text="+" android:textsize="30sp"/> <Button android:id="@+id/sub" android:text="-" android:textsize="30sp"/> <Button android:id="@+id/mul" S.Gokulakrishnan AP/CSE SCSVMV Page 5

android:text="*" android:textsize="30sp"/> <Button android:id="@+id/div" android:text="/" android:textsize="30sp"/> </LinearLayout> <TextView android:id="@+id/textview" android:layout_margintop="50dp" android:text="answer is" android:textsize="30sp" android:gravity="center"/> </LinearLayout> Now click on Design and your application will look as given below. So now the designing part is completed. S.Gokulakrishnan AP/CSE SCSVMV Page 6

Java Coding for the Android Application: Click on app -> java -> com.example.exno3 -> MainActivity. Then delete the code which is there and type the code as given below. Code for MainActivity.java: package com.example.devang.exno3; import android.os.bundle; import android.support.v7.app.appcompatactivity; import android.text.textutils; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; import android.widget.textview; public class MainActivity extends AppCompatActivity implements OnClickListener { //Defining the Views EditText Num1; EditText Num2; Button Add; Button Sub; Button Mul; Button Div; TextView Result; @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //Referring the Views Num1 = (EditText) findviewbyid(r.id.edittext1); Num2 = (EditText) findviewbyid(r.id.edittext2); Add = (Button) findviewbyid(r.id.add); Sub = (Button) findviewbyid(r.id.sub); Mul = (Button) findviewbyid(r.id.mul); S.Gokulakrishnan AP/CSE SCSVMV Page 7

Div = (Button) findviewbyid(r.id.div); Result = (TextView) findviewbyid(r.id.textview); } // set a listener Add.setOnClickListener(this); Sub.setOnClickListener(this); Mul.setOnClickListener(this); Div.setOnClickListener(this); @Override public void onclick (View v) { float num1 = 0; float num2 = 0; float result = 0; String oper = ""; // check if the fields are empty if (TextUtils.isEmpty(Num1.getText().toString()) TextUtils.isEmpty(Num2.getText().toString())) return; // read EditText and fill variables with numbers num1 = Float.parseFloat(Num1.getText().toString()); num2 = Float.parseFloat(Num2.getText().toString()); // defines the button that has been clicked and performs the corresponding operation // write operation into oper, we will use it later for output switch (v.getid()) { case R.id.Add: oper = "+"; result = num1 + num2; break; case R.id.Sub: oper = "-"; result = num1 - num2; break; case R.id.Mul: oper = "*"; result = num1 * num2; break; case R.id.Div: oper = "/"; result = num1 / num2; break; default: break; } // form the output line Result.setText(num1 + " " + oper + " " + num2 + " = " + result); } } S.Gokulakrishnan AP/CSE SCSVMV Page 8

So now the Coding part is also completed. Now run the application to see the output. Output: S.Gokulakrishnan AP/CSE SCSVMV Page 9

Result: Thus a Simple Android Application for Native Calculator is developed and executed successfully. S.Gokulakrishnan AP/CSE SCSVMV Page 10